MATLAB Answers

Anyone have any tips to improve my code for findpeaks() so that I get only the first big peaks for each graph like those in transducers 10,13 and 1 but only one of them per graph? I want the first arrival time. Thanks.

4 ビュー (過去 30 日間)
Timothy Nsubuga
Timothy Nsubuga 2019 年 6 月 20 日
回答済み: darova 2019 年 6 月 20 日
%%This fucntion will graph waveforms and their hilbert transform from one
%%waveform .csv file
%%must add labeling for first peak and this function needs an input
function g = graphData(file)
newStr = extractBetween(file,"_","_"); %get transducer name
table = readtable(file); %read the data into a table
xr = table2array(table); %convert the table into an array(matrix)
x = xr(:,1);
y = xr(:,2);
[up] = envelope(y); %attain the hilbert envelope fo the amplitude
m = [up];
M = find(up == max(m)); %find the max amplitude of the hilbert transform envelope
[pks,locs] = findpeaks(m,1)% find the first peak of the hilbert envelope
loc1 = [locs];
g = plot( x,y, x, up,'-p','MarkerIndices',locs(2000),...
'MarkerSize',10 ); %plot time vs. amplitude vs. hilbert and mark max amplitude of hilbert
xlabel('Time (seconds)');
title("Peak in Hilbert Transform of Signal");
legend("Transducer" + " " + newStr);

  0 件のコメント


回答 (1 件)

darova 2019 年 6 月 20 日
If you want first peak use locs(1)
If you want max peaks use max()
If you want a few maximum peaks use sort()
Did i understand you correctly?

  0 件のコメント



Community Treasure Hunt

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

Start Hunting!

Translated by