Using angdiff with pdist2 for angle data

4 visualizaciones (últimos 30 días)
David Gillcrist
David Gillcrist el 5 de Oct. de 2023
Respondida: David Gillcrist el 5 de Oct. de 2023
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?

Respuesta aceptada

David Gillcrist
David Gillcrist el 5 de Oct. de 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

Más respuestas (0)

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by