【问题标题】:Using Matlab interp3 without calling first to meshgrid使用 Matlab interp3 而不首先调用 meshgrid
【发布时间】:2017-05-15 19:44:23
【问题描述】:

我有一个 MATLAB 3D 矩阵,我想在第三维中插值。我正在使用 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.

有人可以帮忙吗??

【问题讨论】:

    标签: matlab


    【解决方案1】:

    你已经接近成功了,只需要让前两个索引的方向不同:

    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 的大小匹配。
    • 我们对变量的定义不同。我刚刚按照您的方式更新了答案,现在应该可以使用了。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-07-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-05-15
    • 2012-12-12
    相关资源
    最近更新 更多