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일

0 개 추천

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

verzhen Ligai
verzhen Ligai 2016년 5월 8일
Thank you for your answer. It seems like I wasn't so clear on the function of linspace. I tried the linspace values that you have suggested, I didn't get the results that I was expecting. Is there any other way to generate graphs of functions without using linspace? The mathematical questions that I am trying to plot right now already come with answers. And in those sample models, there aren't endpoints. I am a bit confused... Thank you very much.
Image Analyst
Image Analyst 2016년 5월 8일
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
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개)

카테고리

도움말 센터File Exchange에서 Logical에 대해 자세히 알아보기

태그

질문:

2016년 5월 8일

댓글:

2016년 5월 8일

Community Treasure Hunt

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

Start Hunting!

Translated by