fplot graph error getting y=0

18 Ansichten (letzte 30 Tage)
chelsea
chelsea am 16 Nov. 2022
Kommentiert: chelsea am 16 Nov. 2022
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}')

Akzeptierte Antwort

David Hill
David Hill am 16 Nov. 2022
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}')

Weitere Antworten (0)

Kategorien

Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by