Matlab giving incorrect graph for exponential function

Hey, So i'm trying to plot a graph in matlab
n=1.3390
S=2.9368e-05
T=0.0259
fplot(((T^2*n^2.*exp(-(x)./(T*n))).*(((((S^2).*exp((2.*x)/(T*n)))/((T^2)*(n^2)))+1).^(3/2)))/S);
And substituting the values looks like this(without matrix scalar points):
y=((((0.0259)^2*(1.3390)^2*exp(-(x)/((0.0259)*(1.3390))))*((((((2.9368e-05)^2)*exp((2*x)/((0.0259)*(1.3390))))/(((0.0259)^2)*((1.3390)^2)))+1)^(3/2)))/(2.9368e-05))
this graph should look like this (graph from geogebra)
But when I graph it in matlab i I'm not getting the correct graph; I either get an incorrect graph, or something that doesn't make any sense, like this

2 件のコメント

KSSV
KSSV 2017 年 2 月 14 日
That doesn't mean MATLAB is wrong. You have to check your code.
Joshua Carpeggiani
Joshua Carpeggiani 2017 年 2 月 14 日
the thing is that the graph itself is incorrect because when i paste it directly from matlab into another graphing software it plots correctly

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

回答 (1 件)

John D'Errico
John D'Errico 2017 年 2 月 14 日

0 投票

No. Sorry, but you have not written a function that has the properties you claim. In fact, I have a funny feeling that what you have shown us is not what you did anyway, because if you try to execute that line with fplot in it, as you show, it will generate an error message:
n=1.3390
S=2.9368e-05
T=0.0259
fplot(((T^2*n^2.*exp(-(x)./(T*n))).*(((((S^2).*exp((2.*x)/(T*n)))/((T^2)*(n^2)))+1).^(3/2)))/S);
Undefined function or variable 'x'.
That is not a valid call to fplot.
It does generate a plot if I turn that line into a function.
Next, if you read the help for fplot, you would see that it plots the function between the limits [-5,5]. So all the way from -5 to 5. Your function EXPLODES over those limits.
So if instead, I restrict fplot to look at a limited region, then we get a plot, with at least finite values in it.
fplot(@(x) ((T^2*n^2.*exp(-(x)./(T*n))).*(((((S^2).*exp((2.*x)/(T*n)))/((T^2)*(n^2)))+1).^(3/2)))/S,[0.05,0.35]);
It still is not the simple parabola that you seem to expect. So you are still doing something wrong. I have no idea what you plotted in that other tool, but this is not the function that you seem to expect. But then, since you show only the code and not the true function you think you wrote code for, how can I know?

カテゴリ

ヘルプ センター および File Exchange で 2-D and 3-D Plots についてさらに検索

質問済み:

2017 年 2 月 14 日

回答済み:

2017 年 2 月 14 日

Community Treasure Hunt

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

Start Hunting!

Translated by