Question: Homework 2 -MATLAB Scripts and Conditionals Due 6/12, end-of-day. This homework is an individual assignment. Submit your.m files to eCampus by the due date, and

Homework 2 -MATLAB Scripts and Conditionals Due 6/12, end-of-day. This homework is an individual assignment. Submit your.m files to eCampus by the due date, and remember to follow all submission requirements. Exercise 1: Quadratic Following the algorithm you created in HW1, write a MATLAB script to solve a quadratic equation. The roots of a quadratic equation ax2+bxc 0 are given by the formula 2a write a script that takes as user input the coefficients a, b, c and displays to the user the roots ??, x2 of the quadratic equation. Let x, be the smaller of the two roots . If a is zero, print a warning message informing the user of the situation. But, then solve the linear equation for the single root and set x2NaN If b2- 4ac is negative, print a warning message informing the user why there is an error and set x1x2NaN. (MATLAB could solve this, but we'll skip it for now). If b2-4ac is zero, set x2 equal to the unique root x If any of a, b, c are not scalar numbers, print an informative error message and set x,2NaN Test your function extensively with an adversarial mindset. Try to break it (make it crash or behave in undefined or erratic ways). Every time you break it, fix it. Your goal is to make the function able to handle any possible input, and to fail gracefully when the inputs are invalid
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
