Azzera filtri
Azzera filtri

undisired grid size with meshgrid

5 visualizzazioni (ultimi 30 giorni)
Yu Li
Yu Li il 16 Gen 2018
Risposto: Image Analyst il 16 Gen 2018
Hi: I have a three 1-D constant space matrix, and I want to use them to generate a 3D space mesh.
the size of each is x: 1*532, y: 1*357, z:1*1072.
after I used the meshgrid:
[X,Y,Z]=meshgrid(x,y,z);
the size of X, Y, Z are : 357*532*1072. but I think they should be: 532*357*1072.
is there any problem with my operation?
Thanks! Li

Risposta accettata

Image Analyst
Image Analyst il 16 Gen 2018
Remember y is rows and thus will be the first index. So it returns an array 357*532*1072 which is 357 rows by 532 columns by 1072 slices. Your y is 357 so that's why it's first and you have 357 rows. When the workspace says n*m*s, the first number is the number of rows, which is y, not x.
x = 1:532; % Columns
y = 1 : 357; % Rows
z = 1 : 1072; % Slices
[X,Y,Z]=meshgrid(x, y, z);
[rows, columns, slices] = size(X)

Più risposte (1)

Matt J
Matt J il 16 Gen 2018
Use ndgrid instead
[X,Y,Z]=ndgrid(x,y,z);

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by