필터 지우기
필터 지우기

How to solve quadratic equation?

조회 수: 4 (최근 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 CenterFile Exchange에서 Magnetic Elements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by