Integral2 With Spherical Harmonics

6 visualizaciones (últimos 30 días)
ADSW121365
ADSW121365 el 27 de Mayo de 2019
Respondida: Star Strider el 27 de Mayo de 2019
I have a function to evaluate a specific spherical harmonic at some nth, mth order for some given Theta,Phi input. Currently I give numerical theta, phi inputs to evaluate these functions. What I would like to do is utalise matlabs integral function to perform integrations utalising this function (the problem is more detailed but I'm starting simple).
function [Ynm] = sphharmcomplex(n,m,Theta,Phi)
%sphharmcomplex - Takes a given n (or l),m and generates the corresponding
%complex spherical harmonic at a point Theta,Phi.
%% Legendre Polynomials P_nm(cos(theta)):
xn = cos(Theta); P_n = legendre(n,xn,'unnorm');
P_nm = P_n(abs(m)+1,:);
%% Normalisation:
a = factorial(n-abs(m)); b = factorial(n+abs(m)); c =((2*n)+1)./(4*pi);
coeff = sqrt(a.*c./b);
%% Calculate Ynm:
Ynm = coeff .* P_nm .* exp(1i.*m.*Phi);
end
What I need to do is rewrite this function such I can assign a function handle to it for a integration of the form:
output = 0;
for n = 1:nlim
for m = -n:n
func = (@Theta, Phi) sphharmcomplex(n,m,Theta,Phi)
ans = integral2(func,Thetamin,Thetamax,Phimin,Phimax)
output = output + ans;
end
end
Is anyone able to help with the changes in syntax required to do this?
Currently it throws an error at the function handle assignment which I can't seem to fix. I believe I may need to convert the function to cartesian coordinates somewhere utalising
X = R.*sin(Theta).*cos(Phi); Y = R.*sin(Phi).*sin(Theta); Z =R.*cos(Theta);
but beyond that I'm really rather stuck.
Any help is greatly appreciated!

Respuesta aceptada

Star Strider
Star Strider el 27 de Mayo de 2019
I can’t run your code because I don’t have all the variables.
The probllem is a typographical error in ‘func’.
Try this instead:
func = @(Theta, Phi) sphharmcomplex(n,m,Theta,Phi);

Más respuestas (0)

Categorías

Más información sobre MATLAB en Help Center y File Exchange.

Productos


Versión

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by