Following is the error while calculating Cosine distance….
Subscripted assignment dimension mismatch. Error in CosineDistance (line 28) Distance(i,j) = - (ClientMean(i,:)'*EvalSet(j,:))/(norm_x*norm_y);
function Distance = CosineDistance(ClientMean, EvalSet) % Calculate Cosine Distance
%
% Inputs:
% ClientSet ---- c* dim matrix
% EvalSet ---- n*dim matrix
% Outputs:
% Distance ---- c*n matrix
if ~exist('ClientMean','var') error('Input arguments error.');endif ~exist('EvalSet','var') error('Input arguments error.');end[c, d] = size(ClientMean);[n, dim] = size(EvalSet);if (d ~= dim) error('Dimensionality disagreement.');endfor i = 1 : c for j = 1 : n norm_x = norm(ClientMean); norm_y = norm(EvalSet); Distance(i,j) = - (ClientMean(i,:)'*EvalSet(j,:))/(norm_x*norm_y); endend
Best Answer