How can I save .mat files inside a for loop without overlapping?
    조회 수: 2 (최근 30일)
  
       이전 댓글 표시
    
채택된 답변
  KSSV
      
      
 2017년 5월 22일
        Why you want to generate multiple .mat files? Check the below two case. You can write all the matrices into a single mat file.
%%If matrices sizes are equal 
m = 10 ; n = 9 ; p = 10 ;
A = zeros(m,n,p) ;
for i = 1:p
    A(:,:,i) = rand(m,n);
end
 save('test.mat','A');
   %%if mat4rices sizes are not equal 
   A = cell(p,1) ;
   for i = 1:p
       m = randi([1 10],1) ;
       n = randi([1 10],1) ;
       A{i} = rand(m,n) ;
   end
    save('test.mat','A');
댓글 수: 1
  KSSV
      
      
 2017년 5월 22일
				Vio Bas Commented:
Thank you very much for your question, that was very helpful. It was exactly what I was looking for! Much more efficient than having a huge amount of .mat files. :D
추가 답변 (0개)
참고 항목
카테고리
				Help Center 및 File Exchange에서 File Operations에 대해 자세히 알아보기
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

