I would like to average every 3 values of an vector in Matlab, and then assign the average to the elements that produced it.
Examples:
x=[1:12]; y=%T
You may find the mean of each trio using:
x = 1:12; m = mean(reshape(x, 3, []));
To duplicate the mean and reshape to match the original vector size, use:
y = m(ones(3,1), :) % duplicates row vector 3 times y = y(:)'; % vector representation of array using linear indices