Question about load .mat files
조회 수: 8 (최근 30일)
이전 댓글 표시
I have a group of .mat files, which have continuous number of name, i.e. from W_star_1.mat to W_star_300.mat. Could I write a code using "for i=1:300" loop to load all of them instead of loading them one by one? Thank you very much.
댓글 수: 0
채택된 답변
the cyclist
2012년 7월 7일
편집: the cyclist
2012년 7월 7일
If you are certain that there is no overlap in variables in all those files, then you can use
for i = 1:300
load(['W_star_',num2str(i),'.mat'])
end
but if some of the variables overlap, you'll need to load them into separate structures, to ensure that later loads don't overwrite earlier ones.
for i = 1:300
S{i} = load(['W_star_',num2str(i),'.mat'])
end
Then you'll need to extract the variables from the structures.
댓글 수: 0
추가 답변 (1개)
mohammad
2012년 7월 7일
First you can save them when all of them are on the workspace
save(['name', '.mat']);
then use
load(['name', '.mat']);
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Workspace Variables and MAT Files에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!