Page 1 of 1

USE MATLAB

Posted: Sun May 15, 2022 10:02 am
by answerhappygod
USE MATLAB
Use Matlab 1
Use Matlab 1 (36.49 KiB) Viewed 46 times
2. Script m-file: Quadratic Formula The solution to the quadratic equation: ar? +bx+c=0 15: x = - 5+1b2-4ac 2a a. Create an m-file that will find the roots of a quadratic equation, and print them out. Your m-file should 1. ask the user for the values of coefficients a, b and c. 2. check if a=0. If so, solve for the single root. 3. print out the root(s), real and imaginary. Your file should also tell the user, in words, if: • the roots are real and distinct (2 real roots). the roots are real and the same (1 double root). • the roots are complex and distinct (2 complex roots). . there is only one root (e.g., when a = 0). Bonus: Warn the user that there is no solution if a and b are both zero. b. Show your electronic file to the instructor for testing c. Print the completed m-file. A complete m-file includes your name and date in comment lines at the top of the m-file. Do not forget to use comment lines throughout the file to explain what key parts of the m-file are supposed to do.