MATLAB: Finding max and min amplitudes from upward crossing

findpeaksupward-crossingzero crossing

I have a 351×117 matrix, with each column representing a time series data. I am looking to write a code that can find the max and min amplitudes along each column (time series). The max and min amplitudes have to be taken only at upward crossing of the waves. See attached picture. I need to find the green amplitudes, not the red ones. I understand that findpeaks can do this, but I am dealing with 117 time series (117 columns in the matrix), and was hoping to write a loop that can do this. Any ideas?

Best Answer

If you just want to find the minimum and maximum value in each column, then you can try this
M = ; % your 351x117 matrix
max_M = max(M);
min_M = min(M);
If findpeaks is necessary, the use this for-loop
pks = cell(1,size(M,2));
locs = cell(1,size(M,2));
for i=1:size(M,2)
[pks{i}, locs{i}] = findpeaks(M(:,i));
end
pks and locs are cell array. You can access the peaks value and location of each column like this
pks{1} % peak value of first column
locs{1} % peak location of first column
pks{2} % peak value of second column
locs{2} % peak location of second column
..
..
pks{117} % peak value of 117 column
locs{117} % peak location of 117 column