File Exchange

image thumbnail


version 1.2 (342 KB) by

A matlab toolbox for spherical harmonics.



View License

* Generate real and complex spherical harmonic functions.
* Visualize spherical functions.
* Inner product in spherical space.
* Decompose spherical function into spherical harmonic components.

Comments and Ratings (3)


Ying (view profile)

Hi Tiago,

Thanks a lot for your comments.

In this toolbox (and in most other Spherical Harmonics toolboxes), the theta is defined in (0,pi) and phi in (-pi,pi) or (0, 2pi), so that the (theta,phi) parametrize a point on the sphere. The theta=-pi/2 case is not well-defined, and based on Legendre formula it should have the same value as theta=pi/2, because P(cos(theta)) should produce the same value.

Again, the table for Y_1^1 you are looking at should only be valid for theta in (0,pi) range. It is the convention of this toolbox (and most other SH toolboxes).

Hope that helps.

Tiago Lobo

Tiago Lobo

Please, check your code for the following examples:

l=1, m=1, theta = pi/2, phi = 0;
l=1, m=1, theta = -pi2/, phi=0;

They should give you -0.3455 and +0.3455 (check the results with the table for the analytical expression for Y_1^1, if necessary).

I point this out, because every single implementation of Spherical harmonics on Matlab that I found online have the same error, and unfortunately it's not only for l=1. If you figure out how to fix it, please let me know.



Remove __MACOSX/ folder in the .zip file.

MATLAB Release
MATLAB 8.2 (R2013b)

Inspired: lagrange interpolation

MATLAB Online Live Editor Challenge

Win cash prizes and have your live script featured on our website

Learn more

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video