算每一列的均值
% X: 1000 * 128
sample_mean = mean(X, 1);
% sample_mean: 1 * 128
每个元素减去所在列的均值
sample_mean = mean(X, 1);
X = bsxfun(@minus, X, sample_mean);
% X的每一行都减去sample_mean向量
二进制文件读写
二进制文件存储二维数组:
fout = fopen(savepath, 'wb');
% 注意,Matlab数组存储中一列是连续内存,故需将矩阵转置
fwrite(fout, reshape(B', 1, size(B,1)*size(B,2)),'int');