Reputation: 21
I have a Matlab script that tells me about great circle paths crossing grid locations, and want to look at the distribution of paths crossing a certain grid location. For some location, I have a vector of azimuths of paths crossing that location,
az_vec
and I want to find the mean, standard deviation, and potentially other quantities of this vector. What I have right now is simply
mean_az = mean(az_vec);
std_az = std(az_vec);
and these work fine for narrow distributions of angles far away from 0/360 degrees, but for distributions including 0 degrees they don't work. E.g.
mean_az = mean([10 350])
should return 0, not 180. I don't think I can use a function like wrapTo180, because then I will have the same problem around 180 degrees.
Is there some way to handle this wrapping problem?
Upvotes: 2
Views: 272
Reputation: 3711
There is a solution in the MATLAB file exchange for this:
>> meanangle([10,340])
ans =
-5.0000
Upvotes: 0