我有一个mat文件(AA),其中有60个矩阵。我希望将矩阵存储到单个矩阵中,并在for循环中使用不同的名称保存它们。但我得到了错误,我不知道如何摆脱。你有什么想法吗?
AA = randn(4,4,60); % this is the matrix w/ 60 matrices in it
for i = 1:60
BB = zeros[4,4, length(AA)]; % pre-allocation
BB(:,:,i) = AA(:,:,i);
filename = ['BB-' num2str(i), 'mat']; % rename the file to have different matrices
save(filename, 'BB')
end但是它不能按照我想要的方式工作!
发布于 2016-08-16 05:18:18
下面是你如何做到这一点:
AA = randn(4,4,60); % this is the matrix w/ 60 matrices in it
for i = 1:60
BB = AA(:,:,i);
filename = ['BB-' num2str(i), 'mat']; % rename the file to have different matrices
save(filename, 'BB')
end不需要预先分配BB。
https://stackoverflow.com/questions/38963108
复制相似问题