Struggling with a MATLAB quadratic equation. I keep getting a complex number as my answer and other errors keep occurring.
Write a MATLAB function that solves a quadratic equation of the form
a*x^2 + b*x + c = 0
The syntax of your function should take the form
[quadRoots1,quadRoots2] = Q1_quadratic (a,b,c);
where
a
,b
andc
are the quadratic coefficients; andquadRoots1
andquadRoots2
are the two determined roots. For the case where only one root is present (for example whena=1
,b=2
andc=1
), you should set your second output toNaN
(not a number). If no roots are present, then set both outputs toNaN
.