Info
이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.
save data of matrix in diffrent MAT files
    조회 수: 3 (최근 30일)
  
       이전 댓글 표시
    
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
      
      
 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
 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
댓글 수: 0
이 질문은 마감되었습니다.
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

