Hi, im trying to plot
f(x,y)= e^(x-y) +x^2 +y^2
but in every way i try to plot it it returns the wrong graph (it should be a paraboloid). This is the code im using:
[X,Y]= meshgrid(-10:10);
Z= exp(X-Y) + X.^2 + Y.^2;
surf(X,Y,Z)
Thank you for your help!

 採用された回答

Ameer Hamza
Ameer Hamza 2020 年 10 月 9 日

0 投票

Paraboloid is Z = X.^2 + Y.^2;
[X,Y]= meshgrid(-10:10);
Z = X.^2 + Y.^2;
surf(X,Y,Z)
Due to exp() term in your equation, you won't necessarily get a paraboloid.

3 件のコメント

Francesco Bellora
Francesco Bellora 2020 年 10 月 9 日
mhh, sorry if i didn't explained myself very well; i tried to plot this function with geogebra or wolfram, and both of them returned to me a paraboloid-like graph; i instead keep getting this:
I don't know if the problem is in the syntax of the code or the funcion, or if its only a problem of scaling...
ty anyway for the quick response
Ameer Hamza
Ameer Hamza 2020 年 10 月 9 日
Yes, the graph generated by GeoGebra has a very small range of z-axis. The following code changes the range.
[X,Y]= meshgrid(linspace(-2,2));
Z = exp(X-Y) + X.^2 + Y.^2;
surf(X,Y,Z)
xlim([-5 5])
ylim([-5 5])
zlim([-1 7])
shading interp
Francesco Bellora
Francesco Bellora 2020 年 10 月 9 日
Thanks!

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeTwo y-axis についてさらに検索

製品

リリース

R2020b

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by