Get max values from a table
조회 수: 4 (최근 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!