error handling for complex equation
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hey,
My problem is that there is an error message to Laguerrsche, firstly because of a matrix multiplication and secondly that the second input of n over k has to be non negative. However, the input is at most 0, since k runs to pc-1. And all values are scalar, if then possibly the r value would be a vector. I see therefore no solution for the indicated problems and thank you in advance for the answer(s).
% Define the fibre characteristics and wavelength
nCore = 1.434;
nCladding = 1.42;
wavelength = 1.23; % microns
coreRadius = 25; % microns(Mü-meter)
% Calculate fibre V number
V = (2*pi*coreRadius/wavelength)*sqrt(nCore^2-nCladding^2);
% Calculate wavenumber
k = 2 * pi / wavelength;
% Calculate Fleckradius
wf = sqrt(2*coreRadius^2/V);
iL=1;
pc =3;
r= [0,0.00001,0.005];
Laguerrsche = symsum(nchoosek(pc-1+iL,pc-1-k)*(-2*r.^2/wf^2)^k/factorial(k), k,0, pc-1);
YFeld= sqrt(factorial(pc-1)*pi/factorial(p-1+iL)) *1/wf* Laguerrsche*exp(-x^2/wf^2)*(sqrt(2)*x/coreRadius)^iL;
plot(r,YFeld)
0 commentaires
Réponses (1)
Alan Stevens
le 8 Mai 2021
nchoosek(pc-1+iL,pc-1-k) Your value of pc-1-k isn't a non-negative integer, but it needs to be for nchoosk.
Also why use symsum rather than just sum?
5 commentaires
Alan Stevens
le 9 Mai 2021
How about
% Define the fibre characteristics and wavelength
nCore = 1.434;
nCladding = 1.42;
wavelength = 1.23; % microns
coreRadius = 25; % microns(Mü-meter)
% Calculate fibre V number
V = (2*pi*coreRadius/wavelength)*sqrt(nCore^2-nCladding^2);
% Calculate wavenumber
k = 2 * pi / wavelength;
% Calculate Fleckradius
wf = sqrt(2*coreRadius^2/V);
iL=1;
pc =3;
r= [0,0.00001,0.005];
Laguerrsche = 0;
for n = 0:pc-1
Laguerrsche = nchoosek(pc-1+iL,pc-1-n)*(-2*r.^2/wf^2).^n/factorial(n)+Laguerrsche;
end
YFeld= sqrt(factorial(pc-1)*pi/factorial(pc-1+iL)) *1/wf* Laguerrsche.*exp(-r.^2/wf^2).*(sqrt(2)*r/coreRadius).^iL;
plot(r,YFeld)
Note that in YFeld you had x, which was undefined. I've replaced it by r in the above, though that's just guesswork on my part!
Voir également
Catégories
En savoir plus sur Labels and Annotations dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
