I have that error: “Your objectşve function is not scalar” But I could not find where I am wrong. This is my code can you look at it?
function G = TD_P_inv_Dual(P_exp,B,A_ax,B_by)
d = size(P_exp,1); %dimentions
m = size(P_exp,3); %number of operators
variable S(1,m,m) %For the dual we have not dual variables instead of that we have variable and in this equation we have S
%variable sigma_e(d^2,d^2,d) hermitian semidefinite
You haven’t shown us the dimensions of W. If m > 1, I don’t think there are any dimensions of W which would make S*W a scalar. Therefore, J will not be a scalar, hence the error message. Based on " Cvx real affine expression (1x2x2 array)" appearing in the title of your question, I presume J evaluates to 1 by 2 by 2, which is not a scalar, which it needs to be in order to be used as the objective.
Also, you calculate W_hat but don’t use it, at least in the code that is shown.
The objective must evaluate to a real scalar. It is your optimization problem, so hopefully you know what that real scalar objective function is supposed to be; it can’t be J, because it is not a scalar. I don’t know what objective function you are trying to minimize.