Hi,
"ones(a,b)" returns a-by-b array of ones.
L = ones(length(x),N); %length(x)-by-N array
L(:,1) = ones(1,length(x)); %length(x)-by-1
In the above cases, size of the array returned is different. So, you are replacing with an array of different size that might have changed your result. For more information refer the below doc: