使用Matlab interp3而不首先调用meshgrid

使用Matlab interp3而不首先调用meshgrid,matlab,Matlab,我有一个Matlab3D矩阵,我想在三维空间内插值。我正在使用MATLAB interp3执行此操作: final_3D_mat=interp3( hor_inds_mm, vert_inds_mm, prev_depth_axis_mm,... prev_3D_mat, ... hor_inds_mm, vert_inds_mm, new_depth_axis_mm ) 所使用阵列的大小: size(p

我有一个Matlab3D矩阵,我想在三维空间内插值。我正在使用MATLAB interp3执行此操作:

final_3D_mat=interp3( hor_inds_mm, vert_inds_mm, prev_depth_axis_mm,...
                      prev_3D_mat, ...
                      hor_inds_mm, vert_inds_mm, new_depth_axis_mm ) 
所使用阵列的大小:

size(prev_3D_mat)
size(hor_inds_mm)
size(vert_inds_mm)
size(prev_depth_axis_mm)
size(new_depth_axis_mm)

ans =
   337   507    17
ans =
     1   507
ans =
     1   337
ans =
     1    17
ans =
     1   337
我不想在调用interp3之前调用meshgrid,并使用interp3的X、Y、Z参数作为向量。然而,我不断得到一个错误:

??? Error using ==> interp3 at 128
XI,YI, and ZI must be the same size or vectors of different
orientations.
我试图交换hor_inds_mm和vert_inds_mm参数的位置,但出现了错误:

??? Error using ==> interp3 at 128
The lengths of X,Y and Z must match the size of V.  
我还试图改变向量的方向,如下所示:

final_3D_mat=interp3( hor_inds_mm, vert_inds_mm', permute(prev_depth_axis_mm,[1 3 2]),...
                      prev_3D_mat, ...
                      hor_inds_mm, vert_inds_mm',permute(new_depth_axis_mm,[1 3 2]));
但我也犯了同样的错误:

??? Error using ==> interp3 at 128
XI,YI, and ZI must be the same size or vectors of different
orientations.

有人能帮忙吗???

你已经接近成功了,只需要改变前两个指标的方向:

final_3D_mat=interp3( hor_inds_mm', vert_inds_mm, prev_depth_axis_mm,...
                      prev_3D_mat, ...
                      hor_inds_mm', vert_inds_mm, new_depth_axis_mm ) ;

这样做,我得到的错误:???在128处使用==>interp3时出错X、Y和Z的长度必须与V的大小匹配。我们对变量的定义不同。我只是按照你的方式更新了答案,现在应该可以了。