logical indexing possible to increase speed?
Ältere Kommentare anzeigen
In this loop I convert a 26 Hz accelerometer signal to a 5 seconds interval array. The objective is to find the number of acc values for each 5 second interval. The reason for doing this is that the sample frequency is not exaclty 26, and sometimes there is some missing data in the acc signal. The code works, but takes up a lot of time when processing larger files. My feeling/hope is that creating this new vector can be faster using logical indexing. I just can't figure out how.... Any suggestions?
A = accTimeVector; % Timestamps of acc signal in seconds
length = fix(A(length(A))/5);
acc_5s_interval = zeros(1,length); % create vector with 5 sec intervals
j=0;
for i = 1:length(acc_5s_interval)
acc_5s_interval(i) = numel(A(A>= j & A < j+5));
j=j+5;
end
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Loops and Conditional Statements finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!