Using cvx/sqrt incorrectly
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.
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:
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.
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.
But this become a valid expression when I change it to { } . Otherwise, it is an invalid expression with ( ) .
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.



