Hi,
The error message occurs when you try to assign to a variable, but the indices of the left- and right-hand side of the assignment are incompatible. For example,
A(1) = [1 2 3];
throws this error because the size of the left-hand side is 1-by-1, but the size of the right-hand side is 1-by-3.
In your case, the RHS 'L_k(k,:).*(x-x(j))/(x(k)-x(j))' might be returning an array or vector which is not compatible with the LHS. Could you try storing the result of the RHS in a new varibale and check for its dimensions.