To calculate the moving maximum of a vector in MATLAB, you can use the movmax
function from the Signal Processing Toolbox. This function calculates the maximum value of a moving window with a specified length. Here's an example:
main.m206 chars10 lines
This will output:
main.m31 chars2 lines
Note that the first two values are NaN
because the window size is larger than the available data.
To calculate the moving maximum for each row or column of a matrix, you can use the movmax
function along the appropriate dimension. For example, to calculate the moving maximum for each column of a matrix A
, set moving_max = movmax(A, window_size, 1);
.
gistlibby LogSnag