# "Too many input Argument" error in optimize a matrix w

(Mana Mountain) #1

I have the code to find matrix w optimal:

"prompt = 'How many relays N do you want? ';
n = input(prompt) %numbers of relay N
snrthreshdb=10;
snrthesh=10^(snrthreshdb/10);
phi2=1; %0db
Psdb=14;%14db
Ps=10^(Psdb/10);
In=eye(n,n)%Identity matrix nxn
fRn=zeros(1,n)
gRn=zeros(1,n);
hRn=zeros(1,n);
cEn=zeros(1,n);
phifc=zeros(1,n);
phigc=zeros(1,n);
phifh=zeros(1,n);

for count=1:n
fRn(1,count)=normrnd(0,1)+normrnd(0,1)*i %row vector
gRn(1,count)=normrnd(0,1)+normrnd(0,1)*i %row vector
hRn(1,count)=normrnd(0,1)+normrnd(0,1)*i %row vector
cEn(1,count)=normrnd(0,1)+normrnd(0,1)*i %row vector
phifc(1,count)=fRn(1,count)*cEn(1,count);
phigc(1,count)=gRn(1,count)*cEn(1,count);
phifh(1,count)=fRn(1,count)*hRn(1,count)
end

Rff=diag(fRn);
Rgg=diag(gRn);
Rhh=diag(hRn);
Rfh=phifh*ctranspose(phifh);

for Psum=10:5:40
PRi=Psum/(n+1);
Pn=Psum/(n+1);
Q=Ps * Rff+Pn * Rgg+phi2*In

``````cvx_begin
variable w(n,n) complex
minimize (w')*Q*w %.............................................................error position
(Ps*(w')*Rfh*w)/(phi2*(1+(w')*Rhh*w))>=10;
for count=1:n
w(count,count)*(w(count,count)')*Q(1,1)<=PRi;
end
cvx_end
``````

`end"`

After running the program, I received error message:
"Error using minimize
Too many output arguments.
Error in desRsvsPs (line 40)
minimize (w’)Qw"
Can someone help me solve the problem?

(Mark L. Stone) #2

The error message is because the closing parenthesis is in the wrong place. It should be
`minimize (w'*Q*w)`

However, once you do that, you will encounter another, more serious, error. That is because your objective function evaluates to an n by n matrix. it needs to evaluate to a real scalar. Because I don’t know what you are trying to model, I can’t tell you how to fix it.

(Mana Mountain) #3

This is first time I used cvx to simulate an article so I really don’t know how to make a cvx code from a formula.
I try to simulate formula in red box (the above are parts of formula in red box)

(Mark L. Stone) #4

For starters, w should be a vector, not a matrix.

Then you have more work to do to get the problem into a form CVX can accept, if that is even possible (I leave that to you).