how can we display our real roots or points
5 ビュー (過去 30 日間)
古いコメントを表示
>> f = @(x) x^3-3*x-1;
>> fplot(f, [-10 10]); grid on;
2 件のコメント
Andrew Newell
2015 年 3 月 3 日
Do you want to find the roots or just change the display so you can see the crossings?
採用された回答
Star Strider
2015 年 3 月 3 日
編集済み: Star Strider
2015 年 3 月 3 日
Use the roots function:
xr = roots([1 0 -3 -1]);
They all happen to be real. This gives the x-values, so if you want to plot them, the y vector is:
yr = zeros(size(xr));
4 件のコメント
Star Strider
2015 年 3 月 3 日
I changed ‘r’ to ‘xr’ when I created ‘yr’ and forgot to change it in ‘yr’. The code is consistent now.
With a couple tweaks, you can plot everything easily:
f = @(x) x^3-3*x-1;
xr = roots([1 0 -3 -1]);
yr = zeros(size(xr));
figure(1)
fplot(f, [-10 10], '-r')
hold on
plot(xr, yr, 'bp')
hold off
grid on
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Particle & Nuclear Physics についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!