calculate a secondary peak to peak amplitude after the first peak to peak amplitude in matlab

Assuming you have a signal stored as an array in Matlab, you can calculate a secondary peak-to-peak amplitude as follows:

main.m
% Generate example signal
signal = [1 -2 3 -4 5 -6 7 -8 9 -10];

% Calculate first peak-to-peak amplitude
pp1 = max(signal) - min(signal);

% Find index of the first peak
[~, max_index] = max(signal);

% Calculate secondary peak-to-peak amplitude by finding the minimum and
% maximum values in the section of the signal following the first peak
pp2 = max(signal(max_index+1:end)) - min(signal(max_index+1:end));
412 chars
13 lines

This code generates an example signal, calculates the first peak-to-peak amplitude, finds the index of the first peak in the signal, and then calculates the secondary peak-to-peak amplitude by finding the minimum and maximum values in the portion of the signal following the first peak.

related categories

gistlibby LogSnag