how to load a variable in a loop

1 回表示 (過去 30 日間)
Native
Native 2019 年 8 月 20 日
編集済み: Stephen23 2019 年 8 月 20 日
ROI_epi.mat contains the variable ROI, which I need to load within the loop. How can I do this?
D = dir('CC*/Rest/ROI_epi.mat')
for i = 1:length(D)
a = struct2cell(ROI);
y = a(9,:,:);
%Salience%
ACGl = y{31};
ACGr = y{32};
Insl = y{29};
Insr = y{30};
%DMN%
MOFl = y{25};
MOFr = y{26};
PCCl = y{35};
PCCr = y{36};
IPCl = y{61};
IPCr = y{62};
%CEN%
MFGl = y{7};
MFGr = y{8};
SPCl = y{59};
SPCr = y{60};
%Thal%
lThal = y{77};
rThal = y{78};
TS = horzcat(ACGl,ACGr,Insl,Insr,MOFl,MOFr,PCCl,PCCr,IPCl,IPCr,MFGl,MFGr,SPCl,SPCr,lThal,rThal);
TSd = detrend(TS);
save(['TSd_' num2str(i)])
end

回答 (1 件)

Stephen23
Stephen23 2019 年 8 月 20 日
編集済み: Stephen23 2019 年 8 月 20 日
D = dir('CC*/Rest/ROI_epi.mat');
for k = 1:numel(D)
F = fullfile(D(k).folder,D(k).name);
S = load(F);
ROI = S.ROI;
...
end

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by