I want to solve a matrix least square problem, the solution is a 4*4 matrix. A 4*4matrix multiply a 4*1 matrix obtain a 4*1 matrix. If I repeat the process, it can be represented as a 4*4matrix multiply a 4*N matrix obtain a 4*N matrix, I want to solve the problem in Matlab using for circulation, but the wrong code(N-dimensional indexing allowed for Full matrices only) appeared after running the program.

first form:

for i=1:3

cvx_begin

variable muler(4,4);

minimize(norm(muler(4,4)*xx-double(sp3(:,:,i))));

cvx_end

mu(:,:,i)=muler(4,4);

end

second form:

for i=1:3

sp4=double(sp3(:,:,i));

cvx_begin

variable muler(4,4);

minimize(norm(muler(4,4)*xx-sp4));

cvx_end

mu(:,:,i)=muler(4,4);

end

Both of the code is wrong, how to solve the problem? I use i=3 for simple calculation.