# optim.coder.infbound

Infinite bound support for code generation

Since R2022b

## Syntax

``bnd = optim.coder.infbound``
``bnd = optim.coder.infbound(sz)``
``bnd = optim.coder.infbound(n1,n2,...,nt)``

## Description

````bnd = optim.coder.infbound` creates an infinite bound for use in code generation. `bnd` represents an infinite bound for code generation targets that do not support `Inf`.```

example

````bnd = optim.coder.infbound(sz)` returns an infinite bound array of the same size as the argument `sz`. If `sz` is a scalar, the size of the returned array is `sz`-by-`sz`.```

example

````bnd = optim.coder.infbound(n1,n2,...,nt)` returns an infinite bound array of size `n1`-by-`n2`-by-...-by-`nt` for the scalar values `n1`, `n2`,…,`nt`.```

## Examples

collapse all

Target hardware for code generation does not always accept `Inf` or –`Inf` as a bound. In this case, use `optim.coder.infbound` to represent the infinite bounds.

For example, suppose your problem has upper bounds of `[Inf,1,10]`, meaning `x(2) <= 1` and `x(3) <= 10`, and no upper bound on `x(1)`. The problem also has lower bounds of `[0,``Inf,0]`, meaning `x(1) >= 0` and `x(3) >= 0`, and no lower bound on `x(2)`. You can represent these bounds in several ways.

`ub1 = [optim.coder.infbound 1 10]`
```ub1 = 1×3 Inf 1 10 ```
`lb1 = [0 -optim.coder.infbound 0]`
```lb1 = 1×3 0 -Inf 0 ```
```% Or ub = optim.coder.infbound(1,3); ub(2) = 1; ub(3) = 10```
```ub = 1×3 Inf 1 10 ```
```lb = -optim.coder.infbound([1,3]); lb(1) = 0; lb(3) = 0```
```lb = 1×3 0 -Inf 0 ```

These results are produced from running the code in MATLAB®, and show the MATLAB `Inf` output. When you run `optim.coder.infbound` for code generation, the resulting bounds are appropriate for the target hardware.

## Input Arguments

collapse all

Size of the returned `Inf` array, specified as a vector of positive integers. Generally, the size of the returned array is `sz(1)`-by-`sz(2)`-by-...-by-`sz(t)`, where `t` is the number of components of `sz`. However, if `sz` is a scalar, the size of the returned array is `sz`-by-`sz`.

Example: `[2,3,1,4]`

Data Types: `double`

Size of an `Inf` array component, specified as a positive integer.

Example: `2`

Data Types: `double`

## Version History

Introduced in R2022b