【发布时间】:2017-09-02 05:44:10
【问题描述】:
X(100,371)
%% contains 100 datapoints for 371 variables
我只想保留均值+标准差范围内的数据:均值-标准差。
我是这样处理的:
mx=mean(X);sx=std(X);
%%generate mean, std
%%this generates mx(1,371) and sx(1,371)
mx=double(repmat(mx,100,1));
%%this fills a matrix with the same datapoints,
%%100 times
sx=double(repmat(sx,100,1));
%% this gives mx(100,371) and sx(100,371)
g=X>mx-sx & X<mx+sx;
%%this creates a logical mask g(100,371)
%%filled with 1s and 0s
test(g)=X(g);
%%this should give me test(100,371), but I get
%%test(37100), which is wrong as it doesnt maintain
%%the shape of X
test=reshape(test,100,371)
%% but when I compare this to the my original matrix
%% X(100,371) I hardly see a difference (datapoints
%% in test are still outside the range I want.
我做错了什么?
【问题讨论】:
标签: matlab indexing binary mask