To resolve issues starting MATLAB on Mac OS X 10.10 (Yosemite) visit: http://www.mathworks.com/matlabcentral/answers/159016
n = 10;
for p = 1:n
function  = lal(p)
This method doesn't work.. Why..?
No products are associated with this question.
What does not work about it? What error message is given?
One thing I notice is that in the code you show, if that is the entire code, then you are attempting to define a function inside a script. You need to convert the first part to a function. For example,
function testloop n = 10; for p = 1 : n lal(p) end function  = lal(p) ...