MATLAB: How to incorporate the following lines to Matlab R2013: Because it keeps giving errors that legendrep is not defined

legendre function in matlab 2013

arg = 0.5;
P = legendrep(2,'cos(arg)');
P_n = eval(P);

Best Answer

Since MATLAB is case-sensitive, you needto capitalize the ā€˜Pā€™. This works (in R2015a):
arg = 0.5;
P_n = legendreP(2, cos(arg))
P_n =
0.6552