Hey guys!
I am having trouble when trying to load several mat files which consist of RMN images. The files are struct 1x1 and if I try to create a loop for loading files, Matlab loads only the first image in the variable named cjdata.
Has anyone else had this problem and found a solution?
Thanks!
filenames={'1550.mat','1549.mat','1548.mat','1547.mat','1546.mat','1545.mat','1544.mat',...
'1543.mat','1542.mat','1541.mat'};
for kk = 1:numel(filenames)
load(filenames{kk})
end

댓글 수: 2

Stephen23
Stephen23 2019년 4월 23일
편집: Stephen23 2019년 4월 23일
Beatrice Milik please show us the code you are using, either as text in your question or uploaded as a text file (simply by clicking the paperclip button).
"Has anyone else had this problem and found a solution?"
Most likely you just need to use indexing, exactly like the examples here:
Beatrice Milik
Beatrice Milik 2019년 4월 23일

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

 채택된 답변

Stephen23
Stephen23 2019년 4월 23일
편집: Stephen23 2019년 4월 23일

0 개 추천

It is recommended to load into an output variable, rather than directly into the workspace. doing so also makes your task simpler and easier to understand:
V = 1550:-1:1541;
N = numel(V);
C = cell(1,N);
for kk = 1:N
F = sprintf('%d.mat',V(kk));
S = load(F);
C{kk} = S.cjdata;
end
All of the image data will be in the cell array C.
You can easily adapt this to suit your exact variable class and size: or if this code does not work and you want more help then please upload a sample file.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Structures에 대해 자세히 알아보기

질문:

2019년 4월 23일

편집:

2019년 4월 23일

Community Treasure Hunt

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

Start Hunting!

Translated by