Array indices must be positive integers or logical values.
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Marc Elmeua
el 9 de Sept. de 2021
Comentada: Marc Elmeua
el 12 de Sept. de 2021
I get this error when indexing a variable with peaks found with findpeaks, only when I specify min peak distance and height. Any ideas why this is happening?
acc = ACClowFilt;
peakdistance = 0.5;
epoch = 0.3;
fs = 1000
accdetrend = detrend(acc,0);
% [~, locs] = findpeaks(accdetrend,fs,'MinPeakDistance',peakdistance,'MinPeakHeight',max(acc)*epoch);
[~, locs] = findpeaks(accdetrend);
strideid = zeros(length(acc),1);
strideid(locs) = 1;
strideid = cumsum(strideid);
Thanks in advance!
0 comentarios
Respuesta aceptada
Dave B
el 9 de Sept. de 2021
It looks like when you gave findpeaks a sampling rate it converted the units to time:
[___] = findpeaks(data,Fs) specifies the sample rate, Fs, of the data. The first sample of data is assumed to have been taken at time zero. locs and w are converted to time units.
If you want to keep doing it that way (so your distance is in time units), you could just multiply back out when setting strideid?
load ACClowFilt.mat
acc = ACClowFilt;
peakdistance = 0.5;
epoch = 0.3;
fs = 1000;
accdetrend = detrend(acc,0);
[~, locs] = findpeaks(accdetrend,fs,'MinPeakDistance',peakdistance,'MinPeakHeight',max(acc)*epoch);
%[~, locs] = findpeaks(accdetrend);
strideid = zeros(length(acc),1);
strideid(locs*fs) = 1;
strideid = cumsum(strideid);
Más respuestas (0)
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!