如何调整第3维的Matlab矩阵的大小? [英] How do I resize a Matlab matrix with a 3rd dimension?
问题描述
因此,我想将尺寸为72x144x156的矩阵调整为180x360x156网格.我可以尝试使用以下命令:resizem(precip,2.5)
.前两个维度是纬度和经度,而最后一个维度是时间.我不想调整时间.
So I'd like to resize a matrix that is of size 72x144x156 into a 180x360x156 grid. I can try to do it with this command: resizem(precip,2.5)
. The first two dimensions are latitude and longitude, while the last dimension is time. I don't want time to be resized.
如果矩阵的大小为72x144,则此方法有效.但不适用于尺寸为72x144x156的图片.有没有办法调整前两个尺寸而不改变第三个尺寸?
This works if the matrix is of size 72x144. But it doesn't work for size 72x144x156. Is there a way to resize the first two dimensions without resizing the third?
此外,最快的方法是什么(最好没有for循环).如果需要for循环,那很好.
Also, what is the fastest way to do this (preferably without a for loop). If a for loop is necessary, then that's fine.
推荐答案
D= %existing matrix
scale=2.5;
E=zeros(size(D,1)*2.5,size(D,2)*2.5,size(D,3))
for depth=1:size(D,3)
E(:,:,depth)=resizem(D(:,:,depth),scale)
end
这应该提供预期的输出.
This should provide the expected output.
这篇关于如何调整第3维的Matlab矩阵的大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!