How to use meshgrid and contour

32 ビュー (過去 30 日間)
Sarah Hicks
Sarah Hicks 2019 年 3 月 1 日
回答済み: Star Strider 2019 年 3 月 1 日
x=-2*pi:pi/100:2*pi;
y=-2*pi:pi/100:2*pi;
[X,Y]=meshgrid(x,y);
Z=(sin(2*X).^2)+(cos(2*Y).^2);
figure
contour3(X,Y,Z)
  1 件のコメント
Sarah Hicks
Sarah Hicks 2019 年 3 月 1 日
The plot is not working for some reason. Any help would be greatly appreciated.

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

採用された回答

Star Strider
Star Strider 2019 年 3 月 1 日
I don’t know what you mean by ‘not working’.
This (slighty variation on your posted code) works, and shows the contour3 lines on the mesh plot surface:
x=-2*pi:pi/100:2*pi;
y=-2*pi:pi/100:2*pi;
[X,Y]=meshgrid(x,y);
Z=(sin(2*X).^2)+(cos(2*Y).^2);
figure
mesh(X,Y,Z)
hold on
contour3(X,Y,Z, 'r', 'LineWidth',1)
hold off
grid on
What result do you want if it’s other than this?

その他の回答 (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