function LegPols = LegendrePolynomials(max_deg)

% computes Legendre polynomials upto the maximal degree = max_deg, which are returned in cell array

L0 = [1];
L1 = [1 0];
LegPols = cell(max_deg + 1,1);
LegPols{1} = L0;
if max_deg > 0
	LegPols{2} = L1;
end
if max_deg > 1
	for n = 1:(max_deg - 1)
		LegPols{n + 2} = ((2 * n + 1) * [LegPols{n + 1,1} 0] - n * [0 0 LegPols{n,1}]) / (n + 1);
	end
end

end