Question: Marlab question If a second order polynomial is written in the general form: ax^2 + bx + c = 0 then the roots (i.e. the

 Marlab question If a second order polynomial is written in theMarlab question

If a second order polynomial is written in the general form: ax^2 + bx + c = 0 then the roots (i.e. the values of x that satisfy the equation) can be determined using the quadratic formula: x = -b plusminus Squareroot b^2 - 4ac/2a The test suite workspace includes a vector variable abc that is a 3-element row vector with values for a, b, and c in the first, second, and third column respectively. Write a script mfile to do the following: Check if the roots are real and distinct. Note that the roots will be real if the value under the squareroot is greater than or equal to zero. They will not be distinct, however, if the value under the squareroot is exactly equal to zero. Create an integer variable RootCondition and assign it a value as follows: The value 2 if the roots are real and distinct The value 1 if the two roots are the same. The value 0 if the roots are not real (i.e. complex because the value under the squareroot is less than 0) In cases where there are two real and distinct roots, compute the two roots and assign them in ascending order to a two-element row vector x_solution. In cases where the two roots are the same, solve for the root and assign to a scalar variable x_solution. Do not create the variable x_solution if the roots are complex

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!