How to plot this function

1 回表示 (過去 30 日間)
Dinh Le Dung
Dinh Le Dung 2022 年 8 月 1 日
コメント済み: Star Strider 2022 年 8 月 2 日

採用された回答

Star Strider
Star Strider 2022 年 8 月 2 日
Force the NaN value at (0,0) to be 0
[X,Y] = ndgrid(linspace(-5,5,50));
Z = (X.^3.*Y - X.*Y.^3)./(X.^2+Y.^2);
Z(isnan(Z)) = 0;
figure
surfc(X,Y,Z)
colormap(turbo)
.
  2 件のコメント
Dinh Le Dung
Dinh Le Dung 2022 年 8 月 2 日
It look fanstatic, thanks alot!!!
Star Strider
Star Strider 2022 年 8 月 2 日
As always, my pleasure!

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

その他の回答 (2 件)

Sam Chak
Sam Chak 2022 年 8 月 1 日
Think it should look like this:
[X, Y] = meshgrid(-0.5:1/40:0.5);
Z = X.*Y.*(X.^2 - Y.^2)./(X.^2 + Y.^2);
surf(X, Y, Z), xlabel('x'), ylabel('y'), zlabel('f(x, y)')
  3 件のコメント
Walter Roberson
Walter Roberson 2022 年 8 月 2 日
[X, Y] = meshgrid(-0.5:1/40:0.5);
Z = X.*Y.*(X.^2 - Y.^2)./(X.^2 + Y.^2);
Z(X==0 & Y == 0) = 0;
surf(X, Y, Z), xlabel('x'), ylabel('y'), zlabel('f(x, y)')
Dinh Le Dung
Dinh Le Dung 2022 年 8 月 2 日
Oh it look great!! Thanks a lot!!

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


Abderrahim. B
Abderrahim. B 2022 年 8 月 1 日
Hi!
Since you need to multiply by the truth, maybe this below:
f = @(x,y)((((x.^3).*y - x.*(y.^3)) ./ (x.^2 + y.^2) ).*( x ~= 0 & y~=0) + 0.*( x == 0 & y == 0))
f = function_handle with value:
@(x,y)((((x.^3).*y-x.*(y.^3))./(x.^2+y.^2)).*(x~=0&y~=0)+0.*(x==0&y==0))
[X, Y] = meshgrid([1:.5:10], [0:.1:10]);
F = f(X, Y) ;
surf(X, Y, F)
colorbar
Hope this helps!
  1 件のコメント
Dinh Le Dung
Dinh Le Dung 2022 年 8 月 2 日
I try to zoom in the interval [-0.5, 0.5] but it seems like it does not cover the case f(0,0) = 0

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

カテゴリ

Help Center および File ExchangeSurface and Mesh Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by