How to edit a 3D matrix least square problem with for circulation;N-dimensional indexing allowed for Full matrices only

I want to solve a matrix least square problem, the solution is a 44 matrix. A 44matrix multiply a 41 matrix obtain a 41 matrix. If I repeat the process, it can be represented as a 44matrix multiply a 4N 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
variable muler(4,4);

second form:
for i=1:3
variable muler(4,4);
Both of the code is wrong, how to solve the problem? I use i=3 for simple calculation.

Show us the output of ’whos' from just before the minimize statement, so that we know what the dimensions are everything are. Here is a hint: if instead of declaring mule as a CVX variable, you just make up a numerical matrix of the same dimensions, such as eye(4), the expression inside the minimize() better be conformal, i.e., should evaluate in MAT:AB without producing an error message. Get that correct first. Then go back to declaring mule as a CVX variable.

is it your intention that the expression being minimized is a vector? If so, then norm is what you likely want. However, if the result is supposed to be a (non-vector) matrix, then perhaps you want norm(…,‘fro’)/.

Thank you!

This is a right code:


variable muler(4,4);

The out put is named as muler, it is a 44 matrix, when we have many other sp5, then sp5 changed to a 46N matrix, xx remains the same, a 46 matrix, the output should be N number of 4*4 matrix. I want to realize the process by a circulation rather than calculate the muler one by one, then there is a problem that I can’t realize it.
I want to use only three sp5 to calibrate the code.
The other two sp5 are:
sp5=[29131 36241 42214 46221 47758 48472;
3770 5608 10524 16486 24328 31739;
28194 20933 13914 7758 4132 3847;
46757 46275 43207 38334 32333 24727];

sp5=[28774 36492 42283 45925 47956 47889;
3727 5551 10458 16821 24298 31181;
28234 20971 13511 7949 4094 3786;
46605 45726 42739 38324 31713 24225 ];

It sounds like you have N separate optimization problems to run. So use a for loop;

% sp is 4 by 6 by N array
for i=1:N
  variable muler(4,4);
 % Save the results or do whatever you want
end  :

Thank you very much!
It works, but I don’t know why the first form of code in my original question can’t work, it looks like the same as yours.
Anyway, I am glad it works.
Best wishes!
Thank you!

Your first post has muler(4,4)*xx where it should be muler*xx .
muler(4,4) is just a single element of the matrix, muler, not the entire matrix.

You also presumably want
rather than

Thank you
I’m just beginning to learn to use the CVX tools and I am reading “The CVX Users’ Guide” edited by Michael C. Grant, Stephen P. Boyd, it is useful. I made a mistake that led directly to the code can’t work. In Chinese it would be 差之毫厘谬以千里.
I will study hard and make progress!