Create optimization variables

`x = optimvar(name)`

`x = optimvar(name,n)`

`x = optimvar(name,cstr)`

`x = optimvar(name,cstr1,n2,...,cstrk)`

`x = optimvar(name,{cstr1,cstr2,...,cstrk})`

`x = optimvar(name,[n1,n2,...,nk])`

`x = optimvar(___,Name,Value)`

creates a scalar optimization variable. An optimization variable is a symbolic
object that enables you to create expressions for the objective function and the
problem constraints in terms of the variable.`x`

= optimvar(`name`

)

To avoid confusion, set `name`

to be the MATLAB^{®} variable name. For example,

`metal = optimvar('metal')`

creates a vector of optimization variables that can use `x`

= optimvar(`name`

,`cstr`

)`cstr`

for indexing. The number of elements of `x`

is the same as the
length of the `cstr`

vector. The orientation of
`x`

is the same as the orientation of
`cstr`

: `x`

is a row vector when
`cstr`

is a row vector, and `x`

is a
column vector when `cstr`

is a column vector.

or
`x`

= optimvar(`name`

,`cstr`

1,`n`

2,...,`cstr`

k)

or
`x`

= optimvar(`name`

,{`cstr`

1,`cstr`

2,...,`cstr`

k})

,
for any combination of positive integers `x`

= optimvar(`name`

,[`n`

1,`n`

2,...,`n`

k])`n`

j and names
`cstr`

k, creates an array of optimization variables with
dimensions equal to the integers `n`

j and the lengths of the
entries `cstr1`

k.

,
for any previous syntax, uses additional options specified by one or more
`x`

= optimvar(___,`Name,Value`

)`Name,Value`

pair arguments. For example, to specify an
integer variable, use ```
x =
optimvar('x','Type','integer')
```

.

`OptimizationVariable`

objects have*handle*copy behavior. See Handle Object Behavior (MATLAB) and Comparison of Handle and Value Classes (MATLAB). Handle copy behavior means that a copy of an`OptimizationVariable`

points to the original and does not have an independent existence. For example, create a variable`x`

, copy it to`y`

, then set a property of`y`

. Note that`x`

takes on the new property value.x = optimvar('x','LowerBound',1); y = x; y.LowerBound = 0; showbounds(x)

0 <= x