Quadratic equation & Minus B
5 ビュー (過去 30 日間)
古いコメントを表示
How do I solve the quadratic equation ax^2+bx+c=0 using the minus b formula, x=-b+- sqrt b^2-4ac/2a on MATLAB
Thank you
3 件のコメント
James Tursa
2019 年 5 月 15 日
To read coefficients from the keyboard, you could use the input function
To see if a number is real, you could use the isreal function
採用された回答
kirti singh
2019 年 5 月 16 日
The following example code snippet works for accepting the coefficients a,b and c and calculating the roots and finding if they are real or not:
a1 = 'Enter value of a ';
a = input(a1)
b1= 'Enter value of b ';
b = input(b1)
c1= 'Enter value of c ';
c = input(c1)
x1 = (-b + sqrt(b^2 - (4 * a * c))) / (2 * a);
x2 = (-b - sqrt(b^2 - (4 * a * c))) / (2 * a);
t1=isreal(x1);
t2=isreal(x2);
1 件のコメント
その他の回答 (1 件)
Pavi thra
2020 年 10 月 28 日
a1 = 'Enter value of a ';
a = input(a1)
b1= 'Enter value of b ';
b = input(b1)
c1= 'Enter value of c ';
c = input(c1)
x1 = (-b + sqrt(b^2 - (4 * a * c))) / (2 * a);
x2 = (-b - sqrt(b^2 - (4 * a * c))) / (2 * a);
t1=isreal(x1);
t2=isreal(x2);
0 件のコメント
参考
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!