As already mentioned, you will need a function meanthat, when called without additional arguments, gives the average value for each column in the input. Then a small complication arises, because you cannot just subtract the average value - its sizes differ from the original one.
So try the following:
a = magic(4)
b = a - repmat(mean(a),[size(a,1) 1]) % subtract columnwise mean from elements in a
repmat Replicates the average value according to the size of the data.
source
share