Effacer les filtres
Effacer les filtres

how to load a variable in a loop

3 vues (au cours des 30 derniers jours)
Native
Native le 20 Août 2019
Modifié(e) : Stephen23 le 20 Août 2019
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

Réponses (1)

Stephen23
Stephen23 le 20 Août 2019
Modifié(e) : Stephen23 le 20 Août 2019
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

Catégories

En savoir plus sur Automotive dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by