title: Plotting Hyperbola in Matlab
body: <p>I'm trying to plot a hyperbola in Matlab to simulate a hyperbolic trajectory around the Earth.</p>
  
  <p>Since the hyperbolic equation consists of a +/- part (from the square root), I cannot seem to figure out how to get Matlab to plot this.</p>
  
  <p>This is my code so far:</p>
  
  <pre><code>%Plotting Hyperbolic Orbit
  
   e = 1.05;          %Eccentricity 
   a = -147562.72;    %km
   b = abs(a)*sqrt(e.^2 -1);      %Equation for Semi-Minor Axis, b
  
   x1 = linspace(0.00001, a);         %From 0 to a, Upper
   x2 = linspace(-a, -0.00001);       %From -a to 0, Lower
  
   y1 =  sqrt((b.^2)*((x1.^2)/(a.^2)-1));  %Upper Hyperbola Part
   y2 = -sqrt((b.^2)*((x2.^2)/(a.^2)-1));  %Lower Hyperbola Part
  
  
   figure
   plot(x1, y1, x2, y2, 'b')
   grid on
  </code></pre>
  
  <p>I originally tried with one x coordinate from -a to a, but since 0 is included with this it gave me an imaginary number error and ultimately couldn't plot it.</p>
  
  <p>Any help is appreciated, thanks.</p>