Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/matlab/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
matlab中的快速插值方法_Matlab_Interpolation - Fatal编程技术网

matlab中的快速插值方法

matlab中的快速插值方法,matlab,interpolation,Matlab,Interpolation,我正在使用interp1集成一些数据: temp = 4 + (30-4).*rand(365,10); depth = 1:10; dz = 0.5; %define new depth interval bthD = min(depth):dz:max(depth); %new depth vector for i = 1:length(temp); i_temp(i,:) = interp1(depth,temp(i,:),bthD); end 这里,我通过将测量值从1 m增

我正在使用interp1集成一些数据:

temp = 4 + (30-4).*rand(365,10);
depth = 1:10;

dz = 0.5; %define new depth interval
bthD = min(depth):dz:max(depth); %new depth vector

for i = 1:length(temp);
    i_temp(i,:) = interp1(depth,temp(i,:),bthD);
end

这里,我通过将测量值从1 m增量插值到0.5 m增量来提高测量值的分辨率。这段代码工作得很好,也就是说,它给了我想要的矩阵。然而,当我将其应用于实际数据时,运行需要很长时间,主要是因为我运行的是一个额外的循环,该循环在各个单元格中运行。有没有一种不使用循环就能实现上面描述的功能的方法,换句话说,有没有一种更快的方法

将for循环替换为:

i_temp = interp1(depth,temp',bthD)';
如果您更改
temp
的定义方式,并且如果您同意
i_temp
是19x365数组而不是365x19,则可以消除转置


顺便说一句,for interp1非常清楚,您可以将数组作为第二个参数传入。

for循环中的i_temp是否输入错误?你是说layerP吗?使用
i_temp=interp1(depth,temp,bthD)
会更有意义吗?谢谢,现在修改一下,关于Dan Becker提供的答案:我正在寻找一种可以避免循环的解决方案!伟大的我没有意识到转换矩阵会带来不同(使它起作用)。谢谢