Meshgrid matlab的指数

Indices from Meshgrid matlab

我卡在这里这么久了。请帮助我。

对于以下代码:

原始 "I" 尺寸为 217x181x181

[nX,nY,nZ] = 尺寸(I);

[X,Y,Z] = 网状网格(1:nX,1:nY,1:nZ);

Meshgrid X、Y、Z 尺寸为 181x217x181 后

现在从 "I" 如何在 C 矩阵中找到值,使 X、Y、Z 的维度与 C 的维度相匹配。

对于您的情况,您需要使用 ndgrid instead of meshgrid,因为这将为您提供 217x181x181 的矩阵。您应该查看以下内容以更好地比较这两个函数:

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

总结一下:

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.