Peak detection without using findpeaks()

Following is the code to find peaks.What input should be given to run the function along with threshold.I tried giving both file and the col as inputs,but fail to detect peaks.I gave 0.75 as the threshold.Attached is the data I am working with. There is something else going on with logic,please help!
file = 'forRef_2.xls';
col = xlsread(file,'J:J');
function [peaks, locations] = peakdet (mag, threshold)
len = length(mag);
prev = 1;
cur = 2;
next = 3;
k = 1; %number of peaks
while next < len
if mag(cur) - mag(prev) > threshold
if mag(cur) > mag(next)
peaks(k) = mag(cur);
fprintf('peak at %d has magnitude %d\n', cur,mag(cur));
k = k + 1;
end
end
prev = cur;
cur = next;
next = next + 1;
end
end

7 comentarios

Jan
Jan el 18 de Abr. de 2017
Editada: Jan el 18 de Abr. de 2017
What is your question?
preeti visweswaran
preeti visweswaran el 18 de Abr. de 2017
I am unable to see the code
preeti visweswaran
preeti visweswaran el 19 de Abr. de 2017
My question is how do i find peaks using the function peakdet in code.I want to have the file,and threshold as input
KSSV
KSSV el 19 de Abr. de 2017
There are seven columns in the file...you want to find the peaks for each column? And what is threshold?
preeti visweswaran
preeti visweswaran el 19 de Abr. de 2017
the threshold is 0.75 and on the last column Mean_Acc
KSSV
KSSV el 19 de Abr. de 2017
So you want to find the maximum value which is less then the threshold from the column?
preeti visweswaran
preeti visweswaran el 19 de Abr. de 2017
I want to detect all the Mean_Acc values that are above the 0.75

Iniciar sesión para comentar.

Respuestas (0)

Etiquetas

Preguntada:

el 18 de Abr. de 2017

Editada:

el 19 de Abr. de 2017

Community Treasure Hunt

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

Start Hunting!

Translated by