Clear Filters
Clear Filters

Using angdiff with pdist2 for angle data

3 views (last 30 days)
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?

Accepted Answer

David Gillcrist
David Gillcrist on 5 Oct 2023
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

More Answers (0)

Community Treasure Hunt

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

Start Hunting!