フィルターのクリア

Calculate the roots of quadratic ax^2 + bx + c = 0. For the program, consider the discriminant D, D = b^2 − 4ac

157 ビュー (過去 30 日間)
Kayla
Kayla 2015 年 4 月 8 日
回答済み: AKARSH KUMAR 2020 年 6 月 24 日
If D > 0, display ”The equation has two roots,” and the roots are displayed in the next line. If D = 0, display ”The equation has one root,” and the roots is displayed in the next line. If D < 0, display ”The equation has no roots.” Try the following three equations (a)3x^2 + 6x + 3 = 0 (b) − 3x^2 + 4x − 6 = 0 (c) − 3x^2 + 7x + 5 = 0
What I have. I need to get the same result without using the input function so i can publish it.
  2 件のコメント
Harsh Kumar
Harsh Kumar 2018 年 8 月 11 日
there is not any use of for loop
Image Analyst
Image Analyst 2018 年 8 月 11 日
Not true. There IS use of a for loop. See the "for" word on the second line of the program? But there doesn't have to be. You can get the roots simply by using the roots() function.
r = roots([a, b, c]);

サインインしてコメントする。

回答 (1 件)

AKARSH KUMAR
AKARSH KUMAR 2020 年 6 月 24 日
You can refer to this link and use the function to solve higher degree polynomials as well

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by