How to compute the average of distances between a column and other columns of a matrix?

4 ビュー (過去 30 日間)
phdcomputer Eng
phdcomputer Eng 2018 年 12 月 29 日
コメント済み: Rik 2019 年 1 月 2 日
I want to compute the average of distances between a column and other columns in a matrix except itself.
I'm not sure that the if section is true or not.
the data matrix is nXm size
I'll be grateful to have your opinion.
for i=1:m
for j=1:m-1
if(i==j)
t=0
else
t=pdist2(data(:,i),data(:,j),'jaccard');
b=sum(t)/(m-1);
end
end
end
plot(b)
  3 件のコメント
phdcomputer Eng
phdcomputer Eng 2019 年 1 月 2 日
Thank you
This point you mentioned is my question too, in this code , how to define a vector of values for saving all of the distances in iterations? Are t and b two vectors or just variables?
for i=1:m
for j=1:m-1
if(i==j)
t=0
else
t=pdist2(data(:,i),data(:,j),'jaccard');
b=sum(t)/(m-1);
end
end
end
plot(b)
Rik
Rik 2019 年 1 月 2 日
Use the debugger to step through your code line by line and see what happens. That's how I would find out.
The debugging tools are one of the points where Matlab crushed the competition by GNU Octave, so you should really learn to use them.

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

回答 (0 件)

カテゴリ

Help Center および File ExchangeMATLAB Coder についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by