I need to loop a code i was given

7 次查看(过去 30 天)
I was given a code that was tested on a single participants data to see if it would do what we were intending it to do (defining baseline timeframe), now I need to loop the code to be able to run all of my participants. This is the current code with the participant number included.
raw(20).draw %see this one
stim = nirs.design.StimulusEvents;
stim.name = 'Temp';
stim.onset = [35 raw(20).time(end)-35];
stim.dur = [1 1];
stim.amp = [1 1];
raw(20).stimulus('Temp') = stim;
figure; raw(20).draw %You can see the stim events
job = nirs.modules.TrimBaseline();
job.preBaseline = 10;
job.postBaseline = 10;
raw(20) = job.run(raw(20));
figure; raw(20).draw %see after remove the spikes
job = nirs.modules.KeepStims();
job.listOfStims = '';
raw(20) = job.run(raw(20))
figure; raw(20).draw
This is the error i get when i remove the participant idendifier (20) or try to replace it with (1:24)
Expected one output from a curly brace or dot indexing expression, but there were 24
results.
essentially i need to define the loop for this code that i have.
Thanks so much for helping out.

回答(1 个)

Jan
Jan 2021-6-28
for k = 1:24
... your code, but replace "20" by k
end

类别

Help CenterFile Exchange 中查找有关 MATLAB 的更多信息

标签

产品


版本

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by