필터 지우기
필터 지우기

Quick question about "surf" or "surfc"

조회 수: 4 (최근 30일)
seyedashraf
seyedashraf 2011년 12월 5일
편집: seyedashraf 2021년 12월 6일
Hi
The problem is, I need to plot a 3D surface in each loop of my computations, lets say water depth. the computational domain is rectangular but it is not square, so the number of elements in X direction is not the same as the number of elements in Y direction.
for square domains I used to use the command :
xx1=linspace(0,Xlength,NX);
yy1=linspace(0,Ylength,NY);
[x1,y1]=meshgrid(xx1,yy1);
surf(x1,y1,z);
view(125,20);
but when managing to use a non-square domain it gives the error:
??? Error using
==> surf at 78
Data dimensions
must agree.
Error in ==>
test at 53
surf(x1,y1,z);
removing the x1,y1 from the surf(x1,y1,z) command gives a 3D with the wrong scale and it is not useful at all
, so please advice

채택된 답변

Sean de Wolski
Sean de Wolski 2011년 12월 5일
size(x1)
size(y1)
size(z)
Will show that not all three matrix sizes are the same. Remember meshgrid swaps the inputs unlike ndgrid
  댓글 수: 3
Walter Roberson
Walter Roberson 2011년 12월 5일
Yup, but that 2D domain was not produced by meshgrid.
Use ndgrid() instead of meshgrid() to do what you want.
seyedashraf
seyedashraf 2011년 12월 5일
Thanks Sean de Wolski. Thanks Walter Roberson, that replacement made it work.

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

추가 답변 (0개)

카테고리

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