# error handling for complex equation

1 view (last 30 days)
Anna-Lena Geppert on 7 May 2021
Commented: Anna-Lena Geppert on 10 May 2021
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;
wavelength = 1.23; % microns
% Calculate fibre V number
% Calculate wavenumber
k = 2 * pi / wavelength;
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);
plot(r,YFeld)

Alan Stevens on 8 May 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?
Anna-Lena Geppert on 10 May 2021
okay, thank you. :)