Quick question about "surf" or "surfc"
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
seyedashraf
am 5 Dez. 2011
Bearbeitet: seyedashraf
am 6 Dez. 2021
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
0 Kommentare
Akzeptierte Antwort
Sean de Wolski
am 5 Dez. 2011
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 Kommentare
Walter Roberson
am 5 Dez. 2011
Yup, but that 2D domain was not produced by meshgrid.
Use ndgrid() instead of meshgrid() to do what you want.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Surface and Mesh Plots finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!