Here's an approach you could use to reduce the dimensions of a matrix in MATLAB by averaging a range of columns, with the range of columns getting progressively larger:
A
.n_out
.n
from 1 to n_out
, compute the mean of n
contiguous columns in A
.B
, with each mean occupying a column of B
.B
.Here's what the MATLAB code for this approach might look like:
main.m394 chars14 lines
This code assumes that the number of columns in A
is evenly divisible by n_out
. If not, you'll need to adjust the calculation of col_idxs
accordingly to ensure you're averaging the same number of columns in each step of the loop. Additionally, you may want to add error-checking code to ensure that n_out
is less than or equal to the number of columns in A
.
gistlibby LogSnag