This is my plan on how to write it (don't have software at my disposal currently). I am learning matlab so understand there may be quite a few problems.
Function [x]=myquad(a,b,c)x=[r1 r2];d=sqrt((b.^2)-4.*a.*c)if a==0 & b>0 r1=-c/b;elseif a==0 & b==0 r1=0;elseif a~=0 & d==0 r1=-b./(2.*a);r2=r1;elseif a~=0 & d>0 r1=(-b+d)./2a; r2=(-b+d)./2.*a;elseif a~=0 & d<0 r1=(-b+d.*i)/2a; r2=(-b-d.*i)./2.*a;endend
I need to follow this algorithm for an assignment.
THANKS!
Best Answer