using meshgrid to create a mesh

3 ビュー (過去 30 日間)
Amani Alabri
Amani Alabri 2019 年 1 月 31 日
コメント済み: Amani Alabri 2019 年 2 月 1 日
Hi, I have 3 vectors X,Y,Z and I am trying to create 3D mesh. I first created a matrix for X and Y using meshgrid and then create another meshgrid for Z individually. The length of X and Y is 12 and Z is 12*12. I am not sure if can use meshgrid for Z. the The plot does not look right.
[xxx,yyy]= meshgrid(X, Y);
[zzz]=meshgrid(Z);
mesh(xxx,yyy,zzz);

回答 (1 件)

Ollie A
Ollie A 2019 年 1 月 31 日
I don't think you have to meshgrid(Z), instead your 12x12 Z matrix represents the height of the mesh plot at coordinates specified by the meshgrid X and Y. I think your code should be more like:
x = 1:12;
y = x;
z = ones(12);
[X,Y] = meshgrid(x,y);
mesh(X,Y,z);
I hope that helps!
  1 件のコメント
Amani Alabri
Amani Alabri 2019 年 2 月 1 日
Thank you, Ollie. That will create a matrix Z with ones. I do have Z as a variable which can't be ones.

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

カテゴリ

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