Write a program in MATLAB script to solve the quadratic equa

Write a program in MATLAB (script) to solve the quadratic equation ax^2+bx+c=0 for any values of user inputs a, b, and c. Your program should check for all input possibilities for a, b, and c including zeros.

Solution

%matlab code

a = input(\"Enter a: \");
b = input(\"Enter b: \");
c = input(\"Enter c: \");

polynomial = [a b c];
r = roots(polynomial);
disp(r);

%{
output:
Enter a: 4
Enter b: 5
Enter c: 6
-0.6250 + 1.0533i
-0.6250 - 1.0533i
  

Enter a: 1
Enter b: 5
Enter c: 1
-4.79129
-0.20871
  
  
  
Enter a: 0
Enter b: 1
Enter c: 2
-2

Enter a: 2
Enter b: 0
Enter c: 0
0
0
%}

Write a program in MATLAB (script) to solve the quadratic equation ax^2+bx+c=0 for any values of user inputs a, b, and c. Your program should check for all inpu

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site