Conversion to double from cvx is not possible

(Shahrukh Khan Kasi) #1

I want to solve a simple convex problem that minimizes the power of transmitting devices. I have a supposed that there are 10 devices each communicating with another device. But, when I run the program it gives me this error,

The following error occurred converting from cvx to double:
Conversion to double from cvx is not possible.
Error in testcode4 (line 12)
Rate(i,j) = log(1+(p(i)*((distance(i,j)).^(-pathloss))));

distance = rand(10,10);
Rate_min = ones(10,10);
Power_total = 10;
Rate = zeros(10,10);

variable p(10,1) nonnegative
minimize norm(p)
subject to
for i = 1:10 
    for j = 1:10
        Rate(i,j) = log(1+(p(i)*((distance(i,j)).^(-pathloss))));

Rate >= Rate_min;
sum(p) <= Power_total;

(Mark L. Stone) #2

You are using Rates as an expression, after first having defined it as a MATLAB (double) variable. This is neither allowed nor necessary. See . Had you read that, you would have seen discussion of the exact error message you received.


delete the line Rate = zeros(10,10);


change it to expression Rate(10,10); and move it to someplace after cvx_begin and before the for loops.


change it to Rate = cvx(zeros(10,10));


remove all instances of Rate and instead use
log(1+(p(i)*((distance(i,j)).^(-pathloss)))) >= Rate_min(i,j)

Note: the usage of cvx() doesn’t seem to be in the CVX Users’ Guide.

Cannot perform the operation: {concave} ./ {real affine}