plot using matlab(parabolic)

40 vues (au cours des 30 derniers jours)
Carc
Carc le 25 Jan 2023
Modifié(e) : John D'Errico le 25 Jan 2023
This is watt sepctrum equation, but i don't know why my plot is weired. The plot might be parabolic shape, but mine is not. Could you let me know what's the problem?
x = linspace(10,10^7);
y = 0.453 .* exp(-1.036 .* x) .* sinh((2.29.* x).^0.5);
plot(x,y);

Réponses (2)

John D'Errico
John D'Errico le 25 Jan 2023
It IS curved, though not truly parabolic. A parabola means something specific about the shape, as a polynomial curve. But you just need to look carefully at what you have done. I'll do this for fewer points.
x = linspace(10,10^7,20)
x = 1×20
1.0e+07 * 0.0000 0.0526 0.1053 0.1579 0.2105 0.2632 0.3158 0.3684 0.4211 0.4737 0.5263 0.5789 0.6316 0.6842 0.7368 0.7895 0.8421 0.8947 0.9474 1.0000
y = 0.453 .* exp(-1.036 .* x) .* sinh((2.29.* x).^0.5)
y = 1×20
1.0e-03 * 0.8590 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
So what happened? you had numerical problems. Do you see the NaNs there?
  3 commentaires
Walter Roberson
Walter Roberson le 25 Jan 2023
Note the exp(negative of large large number)
format long g
-1317311753049245359/134217728000
ans =
-9814737.38736842
exp() of negative 10 million is going to be tiny.
John D'Errico
John D'Errico le 25 Jan 2023
Modifié(e) : John D'Errico le 25 Jan 2023
Sorry. I had to end that answer before I was really finished writing. The point is, you are going out as far as 1e7 in x. What happens when x is REALLY REALLY large?
x = 1e7;
exp(-1.036 .* x)
ans = 0
So that subexpression underflows. But what is
sinh((2.29.* x).^0.5)
ans = Inf
And that term overflows. What is the product of 0*inf? That is an indeterminate expression. We could come up with entirely valid arguments that result should be 0, inf, or any finite number. Therefore MATLAb is forced to call it a NaN,
0*inf
ans = NaN
Thus an indeterminate result. It has no value you can assign to it.
In fact, this happens even for relatively small values of x in that interval. Even 1e5 is far too large to let you see anything. I'm not sure whay you are starting at x==10, but you can see stuff happening out there.
x = linspace(10,30);
y = 0.453 .* exp(-1.036 .* x) .* sinh((2.29.* x).^0.5);
plot(x,y)
As I said, this is not at all parabolic.

Connectez-vous pour commenter.


VBBV
VBBV le 25 Jan 2023
x = linspace(0.1,5,100); % may be parabolic
y = 0.453 .* exp(-1.036 .* x) .* sinh((2.29.* x).^0.5);
plot(x,y);
Parabolic probably depends on what range of parameter values you consider in the equation

Catégories

En savoir plus sur Matrix Indexing dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by