File Exchange

image thumbnail

Spherical Harmonics

version 1.1 (265 KB) by Javier Montalt Tordera
Compute spherical harmonic functions.


Updated 10 Dec 2019

View License

This contribution includes a single MATLAB function ('harmonicY') that computes spherical harmonics of any degree and order, evaluated at arbitrary inclination, azimuth and radius. Capabilities include the computation of surface/solid, complex/real and normalized/unnormalized spherical harmonics.

Documentation is provided in the form of a live script with examples, as well as an HTML page for convenience and/or compatibility.

Cite As

Javier Montalt Tordera (2020). Spherical Harmonics (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (5)

Thank you! Your program helped me a lot with my project.

Good job!

Hi Yunus, thank you for your message. I am not sure if I understood you correctly but I presume you were trying to calculate spherical harmonics of large degree and/or order. Unfortunately this function was not designed with such applications in mind, but I updated it and it should now be able to handle those numbers. Naturally, this will only work in the normalized mode, as unnormalized spherical harmonics overflow the double-precision range for n > 150. Please do let me know if this helps!

Hi Javier

Thank you for your work. For EGM2008 Nmax = 2196 does not receive factorial expressions I have the same problem in the code I wrote what can we do in it valid?



- Fix to enable the calculation of large degree and order spherical harmonics.


- Definitely fixed file upload.


- Hopefully fixed file upload.


- Small changes to documentation.

MATLAB Release Compatibility
Created with R2018a
Compatible with any release
Platform Compatibility
Windows macOS Linux