2012-07-12 2 views
0

동의해야합니다매트릭스의 크기는

%% When an outlier is considered to be more than three standard deviations away from the mean, use the following syntax to determine the number of outliers in each column of the count matrix: 

mu = mean(data) 
sigma = std(data) 
[n,p] = size(data); 
% Create a matrix of mean values by replicating the mu vector for n rows 
MeanMat = repmat(mu,n,1); 
% Create a matrix of standard deviation values by replicating the sigma vector for n rows 
SigmaMat = repmat(sigma,n,1); 
% Create a matrix of zeros and ones, where ones indicate the location of outliers 
outliers = abs(data - MeanMat) > 3*SigmaMat; 
% Calculate the number of outliers in each column 
nout = sum(outliers) 
% To remove an entire row of data containing the outlier 
data(any(outliers,2),:) = []; %% this line 

마지막 행은 내 데이터 세트에서 관찰 (행)의 특정 숫자를 제거합니다. 내가 수동으로 1000

%% generate sample data 
K = 6; 
numObservarations = 1000; 
dimensions = 3; 

로 관찰의 수 (행)을 언급했기 때문에 나는 그것을 변경 해달라고하지만 만약 내가 스칼라 출력 오류가 numObservarationsdata에 변경하면 나는 그러나, 내 프로그램에서 나중에 문제를 얻을 수

??? Error using ==> minus 
Matrix dimensions must agree. 

Error in ==> datamining at 106 
    D(:,k) = sum(((data - 
    repmat(clusters(k,:),numObservarations,1)).^2), 2); 

numObservarations 그래서 자동으로 data 행 출력의 양 단지 수를 감지 설정하는 방법이 있나요 : 때문에 나는이 오류가 일치하지 행의 수?

답변

5

나는 오해해야합니다. 내가 말할 수있는 한, 충분해야합니다.

numObservations = size(data, 1);