speed optimization in "for" loops
Show older comments
Hi,
I have an experiment with 864 trials. I have an array named Edf_Trials3, with data of saccadic eye movements during the entire experiment. In some trials I have more than one eye movement, in others there is none.
I have an other array, named Time_EndPpt6, with the time of the stimuli presentation in each trial.
I would like to add the time of the stimuli presentation in the former array "Edf_Trials3", on the same line of the corresponding trial.
For that i'm using 2 loops but it's very very long.
Could you help to simplify my code in order to boost the process ?
I add the two arrays. this is my code:
for (j=1:height(Edf_Trials3))
for(i=1:length(Time_EndPpt6))
if (Edf_Trials3.Trial(j)==i)
Edf_Trials3.EndTime_of_Ppt(j)=Time_EndPpt6(i);
end
end
end
Thanks for your help
1 Comment
Jan
on 24 Oct 2018
I'd omit the strange parentheses for the for and if commands. It works, but does not look Matlabish.
Accepted Answer
More Answers (0)
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!