I have a problem with surface parameters (fsurf)

Hello there, this is my first time using this site for help so if i don't get the etiquette right please do let me know. OK so i am trying to plot the following surface f(x,y)= (3*x^2+y^2)*exp(-x-y) with intervals -2 < x < 2 and -2 < y < 2 i have produced the following code:
syms x y
f(x,y) = (3*x^2+y^2)*exp(-y-x);
fsurf(f,[-2 2 -2 2])
However the results are terrible i have tried changing the parameters and tried using a mesh but i get nowhere. Now i have been using a tool online called Calcplot3D see here https://www.monroecc.edu/faculty/paulseeburger/calcnsf/CalcPlot3D/ this tool displays the function how i would expect it to look, i don't understand why i can't replicate this in matlab.
Any help would be brilliant Best Regards Jake

 채택된 답변

madhan ravi
madhan ravi 2018년 10월 30일
편집: madhan ravi 2018년 10월 30일

1 개 추천

syms x y %edited
f(x,y) = (3*x^2+y^2)*exp(-y-x);
ezsurf(f)
xlim([-2 2])
ylim([-2 2])
zlim([-5 5])

댓글 수: 13

madhan ravi
madhan ravi 2018년 10월 30일
편집: madhan ravi 2018년 10월 30일
"_i don't understand why i can't replicate this in matlab._“
If you use symbolic parameters make sure to use ezsurf()
Thank you, the following code with my function still produces unexpected results, the function looks nothing like that :(
madhan ravi
madhan ravi 2018년 10월 30일
Check edited answer
Jake Simmonds
Jake Simmonds 2018년 10월 30일
편집: Jake Simmonds 2018년 10월 30일
I have checked the function if you run the code you get a plot that looks like sheet of paper that looks like it has been lifted at one corner. However if you use that webtool for the function f(x,y)= (3*x^2+y^2)*exp(-x-y) you get the proper function!
madhan ravi
madhan ravi 2018년 10월 30일
No not at all matlab is sophisticated than you think there are two figures in my code plus the one which you suggested in the website has a different equation look carefully!!
I guess i haven't made myself clear enough, what i meant to say is that using that tool to evaluate the function i was looking at (3*x^2+y^2)*exp(-x-y) you get a much more expected "normal" plot.
madhan ravi
madhan ravi 2018년 10월 30일
Could you upload the picture of your expected plot ?
madhan ravi
madhan ravi 2018년 10월 30일
zlim([-5 5])
madhan ravi
madhan ravi 2018년 10월 30일
In fact it’s the same plot but the scaling was different that’s why the figure seemed to be different add the previous comment as your last line and see the difference
madhan ravi
madhan ravi 2018년 10월 30일
See the edited answer now
Ah ok, it's still not as nice though is it as the plot above? it's an improvement though so thanks. I think i will stick to that web-tool though.
madhan ravi
madhan ravi 2018년 10월 30일
If you get used to Matlab you may find it easy to manipulate anyways glad that you got the answer for your question , make sure to accept the answer so that people know that question is solved

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Matt J
Matt J 2018년 10월 30일
편집: Matt J 2018년 10월 30일

0 개 추천

f = @(x,y) (3*x.^2+y.^2).*exp(-y-x);
fsurf(f,[-2 2 -2 2])

댓글 수: 2

Should it not have the dot before *exp ? like so: f = @(x,y) (3*x.^2+y.^2).*exp(-y-x); Also this still does not replicate the function as it should be!!!
Matt J
Matt J 2018년 10월 30일
Yes, I have added .*

댓글을 달려면 로그인하십시오.

카테고리

질문:

2018년 10월 30일

댓글:

2018년 10월 30일

Community Treasure Hunt

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

Start Hunting!

Translated by