how to load a variable in a loop

3 visualizaciones (últimos 30 días)
Native
Native el 20 de Ag. de 2019
Editada: Stephen23 el 20 de Ag. de 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

Respuestas (1)

Stephen23
Stephen23 el 20 de Ag. de 2019
Editada: Stephen23 el 20 de Ag. de 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

Categorías

Más información sobre Automotive en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by