Using cvx/sqrt incorrectly

Uncategorized
Aug 18, 2022
L

There is the original formula :

But I have a problem:

Please help me to solve this problem! Thank you very much!

M

z1 >= square_pos(norm((x,y)-(w1,w2))

or

z1 >= sum_square((x,y)-(w1,w2))

L
Replying to #2

But why the expression I use is wrong?
System prompt: Invalid expression. Use parentheses when calling a function or indexing a variable. Otherwise, check for unmatched delimiters.

M

I don’t see why the error is occurring. But apparently MATLAB doesn’t “like” something, because it is showing red squiggles. Please copy and paste complete reproducible code for the entire program into your post and use preformatted text icon.

J
Replying to #3

Could it be that you might have used Chinese parentheses somewhere?

L
Replying to #4

When I use:
cvx_begin
variable x_opt(2,1000);
variable y_opt(2,1000);
expression tempRate(48,1)
for i=1:2
for k=1:K
% re2(1+(i-1)U:iU)=sum_square((x_opt(i,o),y_opt(i,o))-(w(k,1),w(k,2))); % parenthesis is wrong
re2(1+(i-1)U:iU)=sum_square({x_opt(i,o),y_opt(i,o)}-{w(k,1),w(k,2)});
end
end

But the running result shows:

M

I don’t know what the Chinese error messages say.

Why are you using { } instead of ( ) ?

J
Replying to #7

it says "the operand of type ‘cell’ don’t support the operator ‘-’ ".

M

Thanks. Makes sense because of use of { }, which specifies a cell.

@Linxi If parentheses are in the wrong place, put them in the right place. Don’t use braces where parentheses should be used.

L
Replying to #9

There have been a lot of problems lately. Thank you very very much for your patience.

L
Replying to #5

No, I have checked that no Chinese symbols are used.
But this become a valid expression when I change it to { } .
But Mark said { } was wrong.

L
Replying to #9

But this become a valid expression when I change it to { } . Otherwise, it is an invalid expression with ( ) .

M

Perhaps you should reenter your code in a new file, starting from scratch. Maybe something is corrupted (for example, unprintable character in the code which is causing error). Or @jackfsuia’s previous comment regarding using wrong version of characters.