Get max values from a table
3 次查看(过去 30 天)
显示 更早的评论
From the attached .mat file i would like to get the max values. See picture below, there are 4 peaks, i would like to get all the max x and y values.
1 个评论
Adam Danz
2018-12-12
Your mat file conains one variable 'Ft2' that is a 2669x2 table. Each element of the table is a 1x11 char such as '2.30002e-01'. Since you've plotted the data, you must have converted them to numeric arrays. If you attach numerical data it will be a lot easier to help you.
For starters, have you tried using findpeaks()?
回答(2 个)
Jan
2018-12-12
As adam said already, import the data numerically, not as strings.
The signal looks like a mix of two frequencies. Do you want to remove the high frequence noise at first? Then finpeaks will be more accurate.
0 个评论
Luna
2018-12-12
编辑:Luna
2018-12-12
Hi Jesse,
Please try this below. This code actually finds the 4 max values.
But also you can try to get a moving average (using smooth function to get rid of noise in your signal.)
load('matlab.mat')
xValues = str2num(Ft2.time); % convert x values: time
yValues = str2num(Ft2.combi); % convert y values: combi
[PKS,LOCS]= findpeaks(yValues,'MinPeakDistance',300); % find peaks with avoiding noisy peaks
peakTimeStamps = xValues(LOCS(PKS>10000)); % find peaks as local max and find time stamps of them
peakValues = PKS(PKS>10000); % get the peak values with same filter
% plot
plot(xValues,yValues);
hold on;
plot(peakTimeStamps,peakValues, 'ro');
0 个评论
另请参阅
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!