create mesh from X,Y

11 ビュー (過去 30 日間)
Sumant Jha
Sumant Jha 2016 年 2 月 12 日
コメント済み: Sumant Jha 2016 年 2 月 12 日
I think it is something simple to do, but I can not figure it out. I would like to create a mesh grid from X, Z data. The data is sort of like this:
X= 0:1:500;
Z = 5:10:5000;
I can not use the triangular mesh and so no delaunay or TriScatteredInterp functions. I tried using something simple like:
x=X;
y = X;
[p,q,r]= meshgrid(x,y,Z);
surf(p,q,r);
But this does not works. I get an error that the CData must be an M-by-N matrix or M-by-N-by-3 array. How do I get this working?

回答 (1 件)

Mike Garrity
Mike Garrity 2016 年 2 月 12 日
No, meshgrid with 3 inputs is going to give you a 3D grid. You still want a 2D grid for surf. I think that you're just trying to change the order of the arguments to surf:
[a,b] = meshgrid(0:500,5:10:5000);
z = randn(size(a));
surf(a,z,b,z,'EdgeColor','none')
axis equal
  1 件のコメント
Sumant Jha
Sumant Jha 2016 年 2 月 12 日
Thanks for the answer. Now I am curious, how do we get the 3-D grid. Because, the grid I want has to has X and Y and Z with X = Y and Z being the value of the cell formed by grid?

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

カテゴリ

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