Using angdiff with pdist2 for angle data

3 次查看(过去 30 天)
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 个)

标签

Community Treasure Hunt

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

Start Hunting!

Translated by