フィルターのクリア

Following is the error while calculating cosine distance

1 回表示 (過去 30 日間)
Balaji M. Sontakke
Balaji M. Sontakke 2019 年 4 月 9 日
コメント済み: Balaji M. Sontakke 2019 年 4 月 11 日
Following is the error while calculating cosine distance....
Conversion to cell from double is not possible.
Error in CosineDistance (line 26)
Distance(ctr) = - (ClientMean(i,:)'*EvalSet(j,:))/(norm_x*norm_y);
Error in Evaluation (line 83)
Distance = CosineDistance(ClientMean, EvalSet);
Error in DorsalHandVeinVerification (line 69)
[EvalFAR, EvalFRR, EvalEER, Thr] = Evaluation(TrainSet, gndTrain, EvalSet, gndEval,
options);
function Distance = CosineDistance(ClientMean, EvalSet) % function definition
% 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.');
end
if ~exist('EvalSet','var')
error('Input arguments error.');
end
[c, d] = size(ClientMean);
[n, dim] = size(EvalSet);
if (d ~= dim)
error('Dimensionality disagreement.');
end
Distance=cell(c,n); % pre-allocate
ctr=1;
for i = 1 : c
for j = 1 : n
norm_x = norm(ClientMean);
norm_y = norm(EvalSet);
Distance(ctr) = - (ClientMean(i,:)'*EvalSet(j,:))/(norm_x*norm_y);
ctr=ctr+1;
end
end
end

採用された回答

KSSV
KSSV 2019 年 4 月 9 日
編集済み: KSSV 2019 年 4 月 9 日
cell is accessed using flower braces i.e {}. Replace Distance(ctr) with Distance{ctr}.
function Distance = CosineDistance(ClientMean, EvalSet) % function definition
% 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.');
end
if ~exist('EvalSet','var')
error('Input arguments error.');
end
[c, d] = size(ClientMean);
[n, dim] = size(EvalSet);
if (d ~= dim)
error('Dimensionality disagreement.');
end
Distance=cell(c,n); % pre-allocate
ctr=1;
for i = 1 : c
for j = 1 : n
norm_x = norm(ClientMean);
norm_y = norm(EvalSet);
Distance{ctr} = - (ClientMean(i,:)'*EvalSet(j,:))/(norm_x*norm_y);
ctr=ctr+1;
end
end
end
  2 件のコメント
Balaji M. Sontakke
Balaji M. Sontakke 2019 年 4 月 9 日
Please see the attachment herewith of my program, cosine distance is calculated or not I dont understand because of following error...
Output argument "T" (and maybe others) not assigned during call to "Evaluation".
Error in DorsalHandVeinVerification (line 69)
[EvalFAR, EvalFRR, EvalEER, Thr] = Evaluation(TrainSet, gndTrain, EvalSet, gndEval, options);
Balaji M. Sontakke
Balaji M. Sontakke 2019 年 4 月 11 日
What happen sir...

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeAxes Transformations についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by