I need to take the max of a subset of a vector and then shift through the vector. For instance the column vector
a=[1;2;3;4;5;6;7]
how can I take max(a(1:3))
, max(a(2:4))
, ..., max(a(5:end))
and place all the output in another vector? I can easily do this with a for loop however I'm looking for an elegant way of doing so using matrix operations in MATLAB and preferably in a single line of code (even though I realize that the matrix operations in MATLAB to do so may likely be using a for loop to implement).
Thank you!