# How to set linspace to infinity

96 views (last 30 days)
verzhen Ligai on 8 May 2016
Commented: verzhen Ligai on 8 May 2016
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 on 8 May 2016
Edited: jgg on 8 May 2016
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.

Show 1 older comment
Image Analyst on 8 May 2016
You'll have to be more specific. Otherwise, just plot them out to some big number and see where the graphs level off to some steady state or asymptote, if they do.
Star Strider on 8 May 2016
verzhen Ligai on 8 May 2016