Filter data series on amplitude as a function of time
1 回表示 (過去 30 日間)
古いコメントを表示
ignacio bobadilla tapia
2021 年 5 月 27 日
コメント済み: Star Strider
2021 年 5 月 28 日
Dear,
Along with greeting, I need to filter a time series, specifically I need to obtain the maximum peak (maximum amplitude that is on the vertical axis), and calculate the time difference (plotted on the horizontal axis) between this peak and the previous peak, in addition to obtain the time difference between the maximum peak and the next peak.
Beforehand thank you very much.
I am attaching code that I have in the meantime and file with the data.
close all, clear all, clc
data=load('data.txt');
t=0:10:4*3600;
plot(t,data)
xlabel('Time (s)')
ylabel('Amplitude (m)')
grid on
0 件のコメント
採用された回答
Star Strider
2021 年 5 月 27 日
Try this —
s = readmatrix('https://www.mathworks.com/matlabcentral/answers/uploaded_files/632075/data.txt');
t = linspace(0,numel(s),numel(s));
[maxpk,idx] = max(s)
[pks,locs] = findpeaks(s, 'MinPeakProminence',0.05);
didx = idx - locs; % Index Difference
dt = t(idx) - t(locs); % Time Difference
figure
plot(t,s)
hold on
plot(t(locs), pks, '^r')
hold off
grid
PeakTable = table(t(locs).',pks(:),locs(:),didx(:),dt(:), 'VariableNames',{'Time','Peak_Amplitude','Location_Indices','Index_Differences','Time_Differences'})
.
6 件のコメント
Star Strider
2021 年 5 月 28 日
‘... how can I always make sure that among the 3 selected peaks, the one with the highest peak is in the center of the 3 ...’
I am not certain that is possible. However I do not know what you are doing, so it may not be a problem.
In any event, if the three highest peaks are in roughly the same positions, it might be best to consider (or simply define) the centre peak the reference regardless of its relative amplitude, and just use it that way.
.
その他の回答 (1 件)
ignacio bobadilla tapia
2021 年 5 月 28 日
1 件のコメント
Star Strider
2021 年 5 月 28 日
Either way.
If the centre peak is always the highest, use it as such. If it as not, use it as the reference anyway.
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!