How to solve quadratic equation?

2 ビュー (過去 30 日間)
Danny Maefengea
Danny Maefengea 2020 年 6 月 13 日
編集済み: Ameer Hamza 2020 年 6 月 15 日
I need help with this question fellas.
Write a function called “QuadRoot”that takes user input for a quadratic function (ax^2+bx+c), a, b and c
and calculates the roots of the function.
Note: if the function does not have any real root, show a message indicating that there
is no real root.
  2 件のコメント
Ameer Hamza
Ameer Hamza 2020 年 6 月 13 日
This seems like a homework question. What have you already tried?
Danny Maefengea
Danny Maefengea 2020 年 6 月 13 日
Here's what I've done.

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

採用された回答

Ameer Hamza
Ameer Hamza 2020 年 6 月 13 日
編集済み: Ameer Hamza 2020 年 6 月 15 日
in your code you wrote
d = sqrt(b*b-4*a*c);
and then check if d > 0. This is not the correct condition. You need to check if
d = b*b-4*a*c;
if d > 0
to check if the root is real or not.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSimulink についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by