findpeaks returns wrong width
Afficher commentaires plus anciens
I have a pulse that repeats 4 times with same period (attached oscilloscope data points). I try to isolate the 4 peaks and respective width imposing that the minimum distance between peaks is very close to the inverse of pulse frequency. I use the code pasted below. As you can see in the resulting table, the width of the third peak is the distance (at half prominence) between the signal and a border vertical line that MATLAB consider to separate two neighbour very close peaks. However to avoid this kind of situations I used the clause 'MinPeakDistance' with a value that is smaller but close to the period of the pulses. Nevertheless the function gives a wrong value for the width of the third peak because still a border with a close peak is considered. Why? How can we correct the problem?
function Results=FindPeaks(file)
folder='replace this string with the folder path where the data file is';
D=csvread(strcat(folder,file),11);
A1 = D(:,2);
t1 = D(:,1);
t = t1;
A = A1;
%number of expected peaks:
%frequency of periodic signal
f=7.0025*10^6;
%sampling interval
s=4*10^(-12);
NExp=round(length(t)*s*f);
%plot raw data with all peaks
figure(1)
plot(t,A1);
findpeaks(A,t,'Annotate','extents');
%create a table with relevant peaks, considering FWHM of the
%prominence.
[pks,locs,fwhm,proms]=findpeaks(A,t,'Annotate','extents','MinPeakDistance',1.4*10^(-7),'MinPeakHeight',0.136,'Threshold',1e-7,'MinPeakProminence',0.1);
PkTime = locs;
Results = table(pks, PkTime, fwhm, proms, 'VariableNames',{'Value','PeakTime', 'FWHM', 'Prominence'});
NAct=length(pks);
disp(NExp)
disp(NAct)
end
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Spectral Measurements dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
