Hello I am stuck on a problem. I am supposed to make a function that solves quadratic equations. If however the function gives complex numbers, it is supposed to give me the anwsers x1=888, x2=888. How do I do this?
if then
I tried;
function [xp,xm] = find_roots(a,b,c)if b^2-4*a*c<0 xp=888 & xm=888else xp=(-b/(2*a))+sqrt(b^2-4*a*c)/(2*a) xm=(-b/(2*a))-sqrt(b^2-4*a*c)/(2*a)end % end function
However it if far from the right anwser. I basically don't know how to do arguments in a function. I even tried the "==" in the if/else statement in my function and it still did not work.
Can anyone help me?
Thanks in advance!
Best Answer