fplot graph error getting y=0

17 ビュー (過去 30 日間)
chelsea
chelsea 2022 年 11 月 16 日
コメント済み: chelsea 2022 年 11 月 16 日
Im creating a graph for a simple function, but instead im getting a line at y=0 plotted. My range needs to be [-4,8] but it seems that when I type negative numbers in my range is when this error occurs. If I make the range [0,8] the graph appears normal but as soon as i change it to even [-1,8] I get just a line at y=0.
Additionally, when I open the figure in a seperate figure window it shows the proper graph, but in the graph that actually appears in the live script it is still y=0. I have no idea why this is happening.
Here is my code:
math=@(x)0.6.*x.^3.*exp(-0.4./x)+1.5.*x.^2.*exp(-0.6.*x);
fplot(math,[-1,8])
xlabel('\bfx')
ylabel('\bfy')
title('y=0.6x^3e^{-0.4/x}+1.5x^2e^{-0.6x}')
%here is what I mean about it working for positive ranges
math=@(x)0.6.*x.^3.*exp(-0.4./x)+1.5.*x.^2.*exp(-0.6.*x);
fplot(math,[0,8])
xlabel('\bfx')
ylabel('\bfy')
title('y=0.6x^3e^{-0.4/x}+1.5x^2e^{-0.6x}')

採用された回答

David Hill
David Hill 2022 年 11 月 16 日
There is a sinularity around -5.6e-4 (advoid this area)
math=@(x)0.6.*x.^3.*exp(-0.4./x)+1.5.*x.^2.*exp(-0.6.*x);
fplot(math,[-4,-.01]);
hold on;
fplot(math,[0,8]);
xlabel('\bfx')
ylabel('\bfy')
title('y=0.6x^3e^{-0.4/x}+1.5x^2e^{-0.6x}')
  1 件のコメント
chelsea
chelsea 2022 年 11 月 16 日
ah yes! thank you!

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

その他の回答 (0 件)

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by