Question: Write a function in MatLab: function [x1, x2, flag ] = quad( a, b, c ) which computes the roots of the quadratic equation ax

Write a function in MatLab:

"function [x1, x2, flag] = quad( a, b, c )" which computes the roots of the quadratic equation ax2 +bx +c = 0. The

input arguments a, b and c (which may take any values) are the coefficients

of the quadratic, and x1, x2 are the two roots (if they exist), which may

be equal. The output argument flag must return the following values, according to the number

and type of roots:

0: no solution (a = b = 0, c _= 0);

1: one real root (a = 0, b _= 0, so the root is c/b);

2: two real or complex roots (which could be equal if they are real);

99: any x is a solution (a = b = c = 0).

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!