Code covered by the BSD License  

Highlights from
pmean.m v1.1 (Sep 2009)

5.0

5.0 | 1 rating Rate this file 2 Downloads (last 30 days) File Size: 4.15 KB File ID: #19643
image thumbnail

pmean.m v1.1 (Sep 2009)

by Carlos Adrian Vargas Aguilera

 

19 Apr 2008 (Updated 21 Sep 2009)

MEAN and STD of angles, polar, cylindrical, spherical or cartesian coordinates!

| Watch this File

File Information
Description

This function calculates the mean and standard deviation of vectors in polar coordinates (and others), that is, from angles and magnitudes.

The usage is very simple:

For polar or cylindrical: Direction, Radius, Height
            [mD,eD] = pmean(D);
      [mD,mR,eD,eR] = pmean(D,R);
[mD,mR,mH,eD,eR,eH] = pmean(D,R,H);

For spherical coordinates: Azimuth, Elevation, Radius
            [mA,eA] = pmean(A);
      [mA,mE,eA,eE] = pmean(A,E,'s');
[mA,mE,mR,eA,eE,eR] = pmean(A,E,R,'s');

For cartesian coordinates:
            [mX,eX] = pmean(X,'c');
      [mX,mY,eX,eY] = pmean(X,Y,'c');
[mX,mY,mZ,eX,eY,eZ] = pmean(X,Y,Z,'c');

where "m" stands for MEAN's, and "e" for STD's.

Input angles should be in radians.

It ignores NaN's.

Enjoy it!
Any comments or bug reports will be very appreciated!

MATLAB release MATLAB 7.7 (R2008b)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (3)
12 Jun 2008 Michael Porter

Thank you for this code. I'd like to know how you make the estimations of the std's?

13 Jun 2008 Carlos Adrian Vargas Aguilera

Hi Michael.

They are the root of the sum of the squared deviations, defined as (dyj/dxi)dxi, for each xi cartesian coordinate. yj=yj(x1,x2,x3) are then the transformation from cartesian to other coordinate system.

Cheers!

19 Feb 2010 jichao zhao

It is not accurate. Try this example
Say, D = zeros(2,1);
R = ones(2,1);
D(1) = 330; D(2) = 0;
 [mD,mR,eD,eR] = pmean(D*pi/180,R);
 polar(D*pi/180,R,'yo')
hold on
 polar(mD*pi/180,mR,'ro')

Please login to add a comment or rating.
Updates
21 Apr 2008

English correction and changes in the help.

21 Sep 2009

v1.1 Fixed IMPORTANT bug with angle STD estimation. Changed help and comments.

Tag Activity for this File
Tag Applied By Date/Time
mean Carlos Adrian Vargas Aguilera 22 Oct 2008 09:58:27
pol2cart Carlos Adrian Vargas Aguilera 22 Oct 2008 09:58:27
cart2pol Carlos Adrian Vargas Aguilera 22 Oct 2008 09:58:27
sph2cart Carlos Adrian Vargas Aguilera 22 Oct 2008 09:58:27
std Carlos Adrian Vargas Aguilera 22 Oct 2008 09:58:27
polar Carlos Adrian Vargas Aguilera 22 Oct 2008 09:58:27
nanmean Carlos Adrian Vargas Aguilera 22 Oct 2008 09:58:27
cart2sph Carlos Adrian Vargas Aguilera 22 Oct 2008 09:58:27
angle Carlos Adrian Vargas Aguilera 21 Sep 2009 13:26:51

Contact us at files@mathworks.com