フィルターのクリア

Form a new matrix based on a distance comparison

1 回表示 (過去 30 日間)
pavlos
pavlos 2014 年 9 月 14 日
編集済み: Matt J 2014 年 9 月 14 日
Hello,
Please help me the following:
Consider a threshold value, "thres=0.5" an a 100x10 matrix
A=rand(100,10);
Take the first row of the matrix,
row1=A(1,:);
and
compute the distances between all the remaining rows of A with row1, lets say with "pdist2".
We take those rows of A with
distance < thres
and create a new matrix B that
includes the respective rows together with row1.
All the other rows with
distance > thres
remain in A.
If there are no
distance < thres
matrix A remains the same.
How the following process is done in Matlab;
Thank you.
Best,
Pavlos

採用された回答

Matt J
Matt J 2014 年 9 月 14 日
編集済み: Matt J 2014 年 9 月 14 日
dist_squared=sum(bsxfun(@minus,A,A(1,:)).^2,2);
idx=(dist_squared<thresh^2);
B=A(idx,:);
A=A(~idx,:);

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeStatistics and Machine Learning Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by