필터 지우기
필터 지우기

Making mesh from independent variables

조회 수: 1 (최근 30일)
Ali Y.
Ali Y. 2011년 7월 13일
I have three variables as vectors (X,Y,Z). They are Longitude, latitude and Depth, respectively. I wanna create a wireframe mesh form these data. In case of my data the variable Z isn't a function of X and Y (i.e. it's an independent variable form X and Y), I can't get Z as a matrix. How can I make a matrix from vector Z, and grid my data to create mesh or surface? Please help me to write this code.I need it vitally. I tried "mesh" and "griddata", but there is something wrong with my code. Thanks in advance,
X=(44:0.30:49); Y=(34:0.30:39); Z=(rand(1,17))*1000; [X1,Y1]=meshgrid(X,Y);

답변 (2개)

Chirag Gupta
Chirag Gupta 2011년 7월 13일
How about meshgrid?
[x,y,z] = meshgrid(X,Y,Z); % Where X,Y and Z are vectors
  댓글 수: 1
Ali Y.
Ali Y. 2011년 7월 13일
Makes this error
??? CData must be an M-by-N matrix or M-by-N-by-3 array
Error in ==> mesh at 151
hh = graph3d.surfaceplot(x,y,z,'FaceColor',fc,'EdgeColor','flat',
...

댓글을 달려면 로그인하십시오.


Sean de Wolski
Sean de Wolski 2011년 7월 13일
doc griddata
doc triscatteredinterp
to get your irregular mesh to a regular one.
Z has to be 17x17 to have a combination for each point in X,Y, it's currently 1x17. Are you sure you don't want:
plot3(X,Y,Z)
?
  댓글 수: 3
Sean de Wolski
Sean de Wolski 2011년 7월 13일
it should be
Z1 = reshape(griddata(X(:),Y(:),Z(:),X1(:),Y1(:)),size(X1));
Ali Y.
Ali Y. 2011년 7월 13일
Sorry, still the same tangled lines (in real data). Though, in the code which I have written for you, it cause "precision problems" in making "Delaunay triangulation" and makes these error.
========================================
??? Error using ==> qhullmx
Error in ==> delaunayn at 117
t = qhullmx(x', 'd ', opt);
and
Error in ==> griddata>linear at 151
tri = delaunayn([x y]);

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by