Using MATLAB programming, also Can you indicate what will go in the command window and what will ...
1 answer below »

Using MATLAB programming, also Can you indicate what will go in the
command window and what will go in the script window. Thanks

The roots of a quadratic equation ax2 bx given by formula c 0 are the 4 ac 2a write a function that take as input the coefficients a, b,c and returns as output the roots x1,x2 o the quadratic equation. Let x1 be the smaller of the two roots. "If a is zero, print a warning message informing the user ofthe situation. But, then solve the linear equation for the single root and set x NaN If b2 4ac is negative, print awarning message informing the user of the situation. But, then solve the equation anyways to find and return the complex roots. If b 4ac is zero, set x2 equal to the unique root x1. If any of a, b, c are not scalar numbers, print an error message informing the user ofthe situation and set x, x2 NaN

Jan 28 2021 08:05 PM

1 Approved Answer

Tara d
answered on
January 30, 2021

5
Ratings,
(16 Votes)

MATLAB CODE
function [x1 x2] = quadratic(a, b, c)
if isscalar(a)==0 || isscalar(b)==0 || isscalar(c)==0 %checking whether values entered are scalar or not
disp('INPUT SHOULD BE SCALAR!')
x1 = NaN;
x2 = NaN;
elseif a == 0 %checking condition whether a=0
disp('The equation has no roots!')
x1 = -c/b; %solving x as linear equation
x2 = NaN;
elseif (b*b - 4*a*c) < 0... 0...="">

## 1 Approved Answer

January 30, 2021## Do you need an answer to a question different from the above? Ask your question!

Tell us more

(Hide this section if you want to rate later)

Was the final answer of the question wrong?

Were the solution steps not detailed enough?

Was the language and grammar an issue?

Does the question reference wrong data/report

or numbers?

Stay Solved :)

5 seconds## Didn't find yours?

Ask a new questionGet plagiarism-free solution within 48 hours

Review Please