x∈R show me the code in matlab

Uncategorized
Oct 18, 2021
L

x∈R
where x is a variable

such as

a=rand(10,1);
B=rand(10,1);
cvx_begin
    variable x(10)
    max(a*x.^2-a*x+B)
 subject to
     x<=inf;x>=-inf;  %**Is that right??**
cvx_end
M

x is unconstrained, so just leave out the “constraints” on it.

However, your objective function is not s a scalar, which makes no sense, and is not allowed. Did you mean to have sum in there?

L
Replying to #2
a=rand(10,1);
  
B=rand(10,1);
cvx_begin
    variable x(10)
    max(sum(a.*x.^2-a.*x+B))
cvx_end

It means that x∈R?

M

Yes, but technically R^n, because x is `n dimensional.