title: How to write a code to judge if a result is real number or complex number and store it in a vector?
body: <p>If I want to compute a root of quadratic equation as follows:</p>
  <pre><code> A=0.07;
   B=1.50+1.31*x_1;
   C=-1.37*x_1+1.08*x_1^2-0.15;
   x_2=(-B+sqrt(B^2-4*A*C))/(2*A)
  </code></pre>
  <p>where <code>x_1</code> is a parameter and I want to pick <code>x_1</code> from a grid <code>linspace(-1.5,2.5,200)</code>. If the value of <code>x_2</code> is a real number, then I store this value in a vector <code>ra</code>, otherwise, <code>x_2</code> is a complex, ignore it. Finally, I will get a vector <code>ra=[x_21, x_22, x_23, ... x_2k]</code>. I am stuck on how to write a code to accomplish it.</p>
  <pre><code>   %I try to write such a code as follows but I am confused about this for loop.
     for x_1=linspace(-1.5,2.5,200)
      if isreal(x_2)=1
       ra==x_2
     elseif isreal(x_2)=0
     end
  </code></pre>