Using angdiff with pdist2 for angle data

4 ビュー (過去 30 日間)
David Gillcrist
David Gillcrist 2023 年 10 月 5 日
回答済み: David Gillcrist 2023 年 10 月 5 日
I have two sets of data phi1 and phi2, and I'd like to know what the pairwise distances are for these two sets. I've tried applying the funtion pdist2 with the added argument angdiff but I get the following error
pdist2(phi1,phi2,@angdiff)
Error using pdist2
Error evaluating distance function 'angdiff'.
Caused by:
Unable to perform assignment because the size of the left side is 1-by-1 and the size of the right side is 1-by-3.
Any idea on how to get around this?

採用された回答

David Gillcrist
David Gillcrist 2023 年 10 月 5 日
I found a solution. I defined a new function called
delta = myAngDiff(alpha,beta)
which takes is expected to take a single value for alpha and a vector for beta and use a for loop to iterate through all the difference between alpha and each intry in beta. Here it is:
function out = myAngDiff(alpha,beta)
out = zeros(length(beta),1);
for i=1:length(beta)
out(i) = abs(angdiff(alpha,beta(i)));
end
end

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeClassification Ensembles についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by