1

I am stuck here since so long. Please help me.

For the following code:

Original "I" dimensions are 217x181x181

[nX,nY,nZ] = size(I);

[X,Y,Z] = meshgrid(1:nX,1:nY,1:nZ);

after Meshgrid X, Y, Z are of dimensions 181x217x181

Now from "I" how to find values in C matrix such that the dimensions of X, Y, Z matches with that of C.

M.B.
  • 110
  • 11

1 Answers1

3

For your case, you will want to use ndgrid instead of meshgrid, as this will give you matrices that are 217x181x181. You should take a look at the following for a good comparison of the two functions:

What is the difference between the NDGRID and MESHGRID functions in MATLAB?

To summarize:

NDGRID is to be used for higher dimensionality use and for when you want the results to reflect matrix/array notation:

MESHGRID is to be used for visualizing data and should be used primarily for when plotting two or three dimensional data.

Community
  • 1
  • 1
gnovice
  • 125,304
  • 15
  • 256
  • 359