find function in for loop
6 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
ROBERTA NOCERINO
el 29 de Ag. de 2019
Respondida: Siriniharika Katukam
el 18 de Nov. de 2019
Hi :)
I'm quite new in Matlab but I'm wondering if anyome could help me.
So, I have a list of fixation_onset and fixation_offset both of them with 19.953 columns and a timestamps_s list and I want to exactly do this but for all the columns. So that I will have the intersection between the first the first onset and offset, between the second and so on.
first_fixation_onset = find (timestamps_s >= fixation_onsets(1,:));
first_fixation_offset = find (timestamps_s <= fixation_offsets(1,:));
first_fixation_idx = intersect(first_fixation_onset,first_fixation_offset);
I've tried something like this but an error occurs regarding the usage of >= becasue the matrix dimensions do not agree (even if in the aboce example it worked)
for i_fixation_onsets = 1:length(fixation_onsets);
fixation_onsets_idx (i_fixation_onsets) = find (timestamps_s (:,i_fixation_onsets) >= fixation_onsets(:,i_fixation_onsets));
for i_fixation_offsets= 1:length(fixation_offsets);
fixation_offsets_idx (i_fixation_offsets)= find (timestamps_s (:,i_fixation_offsets) <= fixation_offsets(:,i_fixation_offsets));
end
end
Hope I've been enough clear :)
0 comentarios
Respuestas (1)
Siriniharika Katukam
el 18 de Nov. de 2019
Hi
In the below lines of code, you are assigning the output of "find" which is an array of values to an element of "fixation_onsets_idx" which can accommodate a single scalar. Hence you got the error of array mismatch.
for i_fixation_onsets = 1:length(fixation_onsets)
fixation_onsets_idx (i_fixation_onsets) = find (timestamps_s (:,i_fixation_onsets) >= fixation_onsets(:,i_fixation_onsets));
end
0 comentarios
Ver también
Categorías
Más información sobre Loops and Conditional Statements 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!