how to write a function for quadratic equation
古いコメントを表示
I wrote this into matlab but it doesn't work, can someone explain why?
function [x1,x2] = QuadraticEquation (a,b,c)
d=b^2-4*a*c;
if d>=0
disp ('two roots exist')
x1=(-b-sqrt(d))/2*a
x2=(-b+sqrt(d))/2*a
plot(x1,0,'rx',x2,0,'rx')
hold on
x=-10:10
y=a*x.^2+b*x+c
plot(x,y)
hold off
else
disp ('no real roots’)
end
3 件のコメント
Matt J
2019 年 12 月 7 日
First explain to us why you think it doesn't work.
Alisha Mistry
2019 年 12 月 7 日
Image Analyst
2019 年 12 月 7 日
You need to pass in something. You can't just click the green Run triangle on the toolbar. See Matt J's Answer below.
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Startup and Shutdown についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
