I have tried to create a function that will find the coefficients of the nth order Legendre polynomial without using syms x, but I have got stuck on how to actually get the coefficients with 2 unknowns in my equation… Can anyone help a bit??
Here's my code :
function [y] = LegendrePoly(n)if n == 0 y = 1;elseif n == 1 y = x;else x = zeros(n+1,1); x(n+1) = 1; x_1 = zeros(n+1,1); x_1(n) = 1; for i=2:n; y(i)=((2*x_1(n))/x_1(n))*x*y(i-1)-(x(n-1)/x_1(n))*y(i-2); endend
Best Answer