Get max values from a table

3 views (last 30 days)
Jesse
Jesse on 12 Dec 2018
Edited: Luna on 12 Dec 2018
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.
untitled.png
  1 Comment
Adam Danz
Adam Danz on 12 Dec 2018
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()?

Sign in to comment.

Answers (2)

Jan
Jan on 12 Dec 2018
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.

Luna
Luna on 12 Dec 2018
Edited: Luna on 12 Dec 2018
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');

Tags

Products

Community Treasure Hunt

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

Start Hunting!