undisired grid size with meshgrid

9 次查看(过去 30 天)
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

采纳的回答

Image Analyst
Image Analyst 2018-1-16
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)

更多回答(1 个)

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

类别

Help CenterFile Exchange 中查找有关 Resizing and Reshaping Matrices 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by