MATLAB: I am unable to get the function which solves quadratic equations to produce 2 outputs

discriminantquadratic formula

I am struggling with my project which requires me to produce a function which solves a quadratic equation. It requires 2 outputs [discriminant, quadRoots]. The roots must also be in row vectors. my function produces the roots but does not show the discriminant,please may someone have a look at my code. Thanks Tom
function [disc, quadRoots] = Q1_15024248(a,b,c)
disc = b^2-4*a*c;
x1 = -b + sqrt(disc)/2*a;
x2 = -b - sqrt(disc)/2*a;
quadRoots = [x1,x2];
end

Best Answer

Here's what I get when I run your function as follows
[disc,quadRoots]=Q1_15024248(4,0,-1)
The discriminant output is fine, but the roots are wrong. They should be at +/- .5
disc =
16
quadRoots =
8 -8