CVX tool doubt...Objective function not scalar

  • {margin: 0; padding: 0;} body {font-size: 13.3333px; line-height: 16.4133px; text-align: start; min-height: 0px; white-space: normal; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, “Courier New”, monospace; font-style: normal; font-weight: 400; text-decoration: none solid rgb(0, 0, 0); white-space: normal; } h1, h2 {font-weight: normal;} .S6EBBD8BF0 { text-align: ; line-height: ; min-height: ; white-space: ; color: ; font-family: ; font-style: ; font-size: ; font-weight: ; text-decoration: none; white-space: ; } .S6EBBD8BF1 { } .S6EBBD8BF2 { line-height: 16.4133px; min-height: 18px; white-space: pre; font-size: 13.3333px; white-space: pre; margin-left: 1em; } .S6EBBD8BF3 { min-height: 0px; } .S6EBBD8BF4 { color: rgb(160, 32, 240); text-decoration: none; } .CodeBlock {margin: 10px 0 10px 0; background-color: #F7F7F7;} .CodeBlock+.paragraphNode {margin-top: 10px;} .lineNode {padding-left: 10px; border-left: 1px solid #E9E9E9; border-right: 1px solid #E9E9E9;} .inlineWrapper:first-child .lineNode,.inlineWrapper.outputs+.inlineWrapper .lineNode {padding-top: 5px; border-top: 1px solid #E9E9E9;} .inlineWrapper:last-child .lineNode,.inlineWrapper.outputs .lineNode {padding-bottom: 5px; border-bottom: 1px solid #E9E9E9;} .lineNode .textBox {white-space: pre;}

M=2;

N=1;

x=randi([0 1], M, N);

H=[0.2399 0.1839;0.1233 0.2400];

[U, S, V]= svd(H);

transmittedsignal = x.*V’.*H;

SNR11 = abs(U(1,1)*H(1,1))/((abs(U(2,1)*H(2,1)))+abs(U(1,2)*H(1,2))+abs(U(2,2)*H(2,2)));

SNR12= abs(U(1,2)*H(1,2))/abs(U(1,1)*H(1,1))+(abs(U(2,1)*H(2,1)))+abs(U(2,2)*H(2,2));

SNR21 = (abs(U(2,1)*H(2,1))/(abs(U(1,2)*H(1,2))+abs(U(1,1)*H(1,1))+abs(U(2,2)*H(2,2))));

SNR22 = abs(U(2,2)*H(2,2))/((abs(U(1,1)*H(1,1)))+abs(U(1,2)*H(1,2))+abs(U(2,1)*H(2,1)));

SNR = [SNR11 SNR12;SNR21 SNR22];

B=10e6;

Datarate11=B*log2(1+SNR11);

Datarate12=B*log2(1+SNR12);

Datarate21=B*log2(1+SNR21);

Datarate22=B*log2(1+SNR22);

cvx_begin

variable x(n);

minimize(-sqrt(x)*SNR);

cvx_end

image

this is the error that I am getting…Can anyone please help me with this… I am new to this CVX tool…Thanks in Advance

You haven’t provided the value of n.

SNR is a 2 by 2 matrix, so if n = 2, the objective function sqrt9x)*SNR would consist of a 2 by 1 vector, multiplied by a 2 by 2 matrix, which has incompatible dimensions and would trigger an error message. That is because
variable x(n) declares x to be an n by 1 vector.

If instead you had
variable x(1,n) with n = 2, then the objective function would be a 1 by 2 vector, times a 2 by 2 matrix, which is a 1 by 2 vector, which is not a scalar, therefore triggering the CVX error message
Your objective function is not a scalar.

If n = 1, the objective function is a 2 by2 matrix, which also isn’t a scalar, and would generate the same error message.

CVX objective function must evaluate to a real scalar. That is the only type of optimization CVX knows. You need to formulate an optimization problem having a real scalar objective function.