Hello,
I have done some more research and now I have this code=
Code:
function L = opdracht1(n)
if n == 0;
L = 1
elseif n == 1;
L = [1;
0]
else
x = zeros (n+1,1);
for j = 0:n;
if mod(n-j,2)==0;
a(j) = (((-1).^((n - j)/2))./(2^n).*(factorial(n + j))./((factorial (j)).*(factorial((n+j)/2)).*(factorial((n-j)/2))));
L = x(j) + a
end
end
end The function of this code is to spit out the coefficients of the legendre polynomial Pn(x). This code works as it calculates the following vector for n= 2, if it starts counting from j=1:
0 1.5000
For some reason it wont calculate from j=0, so I don't get the full solution which is:
-0.5000 0 1.5000
That's the only problem left in this code. When I let it start counting from 0 it produces an error.