Create an anonymous function. Documentation at http://www.gnu.org/software/octave/doc/interpreter/Anonymous-Functions.html
f = @(x) legendre_Pl(x,L);
Then use arrayfun to apply the function, f
to an array [1:N]
Documentation at http://www.gnu.org/software/octave/doc/interpreter/Function-Application.html
CellArray = arrayfun(f, [1:N], "UniformOutput", false);
That gives you a cell array. If you want the answer in a matrix, use cell2mat
G = cell2mat(CellArray);