How to mark what is under the 500 value?

57 Views Asked by At

I would like to mark the peaks that are under 500 with a star or anything and name it 'Q-wave' or to put a colored vertical line in that point? enter image description here

Does anyone know how to do it?

Thank you!!

1

There are 1 best solutions below

0
On BEST ANSWER

Use findpeaks. The following figure and code shows some examples. enter image description here

% Create some data
load sunspot.dat
data = sunspot(1:200,2)*4 + 180;

% Plot the data
plot(data, 'm'); hold on; grid on;
ylim([0,1000]);

% all local maxima
[pks, locs] = findpeaks(data);
plot(locs, pks, 'ro');

% all local minima -- the trick is to invert the data:
[pks, locs] = findpeaks(-data);
plot(locs, -pks, 'bo');

% local maxima greater than 500
[pks, locs] = findpeaks(data, 'MinPeakHeight', 500);
plot(locs, pks, 'r*');

% local minima less than 200
[pks, locs] = findpeaks(-data, 'MinPeakHeight', -200);
plot(locs, -pks, 'b*');

% local maxima less than 400 -- the trick is to apply treshold to the pks
[pks, locs] = findpeaks(data);
locs(pks > 400) = []; % delete unwanted data points
pks(pks > 400) = [];  % delete unwanted data points
plot(locs, pks, 'kV', 'MarkerSize', 5);

legend({
    'data'
    'all local maxima points'
    'all local minima points'
    'maxima greater than 500'
    'minima less than 200'
    'local maxima less than 400'
    });