Combining Matrices into one

조회 수: 2 (최근 30일)
Abin Kuruvilla Mathew
Abin Kuruvilla Mathew 2020년 12월 21일
댓글: Abin Kuruvilla Mathew 2020년 12월 21일
Hi
I have 20 matrices (.mat files) from 20 subjects in the format of 68x68. I would like to combine all of them ito a single MAT file, but that one which reads the following structure 68x68x20?
As of now I've been using the following loop and it reads the following structure 1x29
numfiles = 29;
Ws = cell(1,numfiles);
for k = 1:numfiles
myfilename = sprintf('subject_%d.mat', k);
Ws{k} = importdata(myfilename);
end
Can anyone please correct this code?
Kind regards
Mat

답변 (1개)

per isakson
per isakson 2020년 12월 21일
"I have 20 matrices" are those <68x68 double>? "matrices" implies that. If yes, try
%%
numfiles = 29;
Ws = nan(68,68,numfiles); % <68x68x29 double> (20 or 29??)
for k = 1:numfiles
myfilename = sprintf('subject_%d.mat', k);
Ws(:,:,k) = importdata(myfilename);
end
  댓글 수: 3
per isakson
per isakson 2020년 12월 21일
My code, does it work?
Abin Kuruvilla Mathew
Abin Kuruvilla Mathew 2020년 12월 21일
Dear per isakson
I just checked it and it works just fine!
Thank you very much
Kind regards
Abin

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by