Info

この質問は閉じられています。 編集または回答するには再度開いてください。

save data of matrix in diffrent MAT files

1 回表示 (過去 30 日間)
Rica
Rica 2018 年 7 月 9 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
Hi all, I have a 3dim matrix:
%
A(5000,m,n). m=5 and n=10
How could i save the data of this matrix in diffrent mat files with the names:
Datam_n.mat
Thank you
  1 件のコメント
Adam
Adam 2018 年 7 月 9 日
Use a for loop, create the filenames, index into the array and save.
Why do you want them all in different files though? For a lot of usages they would be better kept together and indexed into.

回答 (1 件)

zhao zhao
zhao zhao 2019 年 3 月 15 日
something like this:
A(4, 4, 5)=1;
[~, N, M]=size(A);
for ii=1:N
for jj=1:M
Charii=num2str(ii);
Charjj=num2str(jj);
Var=A(:, ii, jj);
FileName=['''Data' Charii '_' Charjj '.mat'''];
VarName=['''Var'''];
eval(['save(' FileName ',' VarName ')'])
end
end

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by