MATLAB: How to find peaks along a dimension in a 3d matrix

3d matrixfind peaks

I have a 3x4xN matrix and I want to find the peaks in the data along one dimension of the matrix. For example,
a = rand(3,4,100);
y = a(1,1,:);
[m,n] = findpeaks(y);
This fails because y is a 1x1x100 matrix and findpeaks is looking for a vector. How can I find the peaks in the a(1,1,:) data?

Best Answer

doc squeeze