标签: matlab
如何将x中高于均值的值设置为与均值的差值。
x = [3 15 9 12 -1 0 -12 9 6 1]
答案 0 :(得分:5)
x = [3 15 9 12 -1 0 -12 9 6 1]; m = mean(x); idx = (x>m); x(idx) = x(idx) - m;