If M were assured to divide n you would only need to reshape the data into an M-row matrix, to trasnform each segment into a column, and then take the maximum of each column.
In general, if M doesn't necessarily divide n, the same procedure can be applied but the the last segment (i.e. column) may need to be padded with NaN entries. This works because max ignores NaN values.
n = 21; % Data size
M = 4; % Number of segments. If M doesn't divide n, the last
% segment will be shorter (and will be padded by NaN)
signalArray = rand(1,n); % Example data
t = NaN(ceil(n/M), M); % Define matrix of NaN's with required size
t(1:n) = signalArray; % Fill data (in column-major order). Some entries
% in the last column may be left as NaN
result = max(t, [] ,1); % Maximum of each column
Mdividesn?Mas the number of segments (including the last, possibly shorter segment), or as the segment length (except for the possibly shorter last segment)?