I need to loop a code i was given

7 views (last 30 days)
August Namuth
August Namuth on 28 Jun 2021
Commented: August Namuth on 29 Jun 2021
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.

Answers (1)

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

Categories

Find more on MATLAB in Help Center and File Exchange

Tags

Products


Release

R2019a

Community Treasure Hunt

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

Start Hunting!