How to set linspace to infinity

33 ビュー (過去 30 日間)
verzhen Ligai
verzhen Ligai 2016 年 5 月 8 日
コメント済み: verzhen Ligai 2016 年 5 月 8 日
Good day, everyone!
This is my code for the 3D plot of the equation Z= (X^2+3*Y^2)*exp(-X^2-Y^2). In my code, I set my linspace to (-2,2) as an example. But I was wondering if there is a way to set the linspace for x, y to (0, inf). If I have tried writing that way, no change occurred. (I assume it's an error). Following is my code. x=linspace(-2,2); y=linspace(-2,2); [X,Y] = meshgrid(x,y); Z=(X.^2+3*Y.^2)*exp(-X.^2-Y.^2); meshz(X,Y,Z)
Thank you.

採用された回答

jgg
jgg 2016 年 5 月 8 日
編集済み: jgg 2016 年 5 月 8 日
No, this isn't possible because linspace generates a uniformly spaced vector over the two endpoints. Such a vector on (0,Inf) would have an infinite number of entries and would not be practical. (For example, if would take an infinite amount of memory).
A good alternative would be to identify a limit where the behaviour of your function is "close" to the limiting behavior you want to view then using that point instead. Since your function is exponential, something like:
x = linspace(0,10); y = linspace(0,10);
is probably sufficient.
  4 件のコメント
Star Strider
Star Strider 2016 年 5 月 8 日
Give logspace a go. It might at least help you describe your function at extreme values.
verzhen Ligai
verzhen Ligai 2016 年 5 月 8 日
Thank you for your kind answer.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLine Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by