# generateMATLABFunction

Generate MATLAB functions that evaluate the state and output functions of a neural state-space object, and their Jacobians

## Syntax

## Description

This function generates evaluation functions for the state, output, and Jacobians
of a neural state-space object. You can use these functions to simulate the neural state-space
system and to generate C/C++ code for deployment purposes, for applications such as nonlinear
state estimation and model predictive control. To properly execute, the generated functions
require the Deep Learning Toolbox™ and the data files that store network information, which are also generated in
the process. For more information on the state and output functions of a neural state-space
object, see the corresponding properties of `idNeuralStateSpace`

.
For more information on Nonlinear MPC design, see Nonlinear MPC (Model Predictive Control Toolbox).

`generateMATLABFunction(`

generates, in the current folder, two MATLAB functions that calculate the state of
`nss`

,`stateFcnName`

)`nss`

and its Jacobians, respectively. The second argument is the
desired name of the state function. The state Jacobians function has the same name with the
suffix `Jacobian`

attached at the end. If `stateFcnName`

is empty, no state function or data file is generated.

`generateMATLABFunction(`

also specifies the name of the output function as a third argument. The output Jacobians
function has the same name with the suffix `nss`

,`stateFcnName`

,`outputFcnName`

)`Jacobian`

attached at the end.
If `outFcnName`

is empty, no output function or data file is generated.

**Note**

When `nss`

has a number of outputs equal to its number of states,
the generated output returns only the states. Therefore its Jacobian with respect to the
state (the *C* matrix) is an identity and its Jacobian with respect to
the input (the *D* matrix) is zero.

When `nss`

has a number of outputs greater than its number of
states, the generated output function only contains the non-trivial outputs, that is the
ones related to *y _{2}*(

*t*) =

*H*(

*t*,

*x*,

*u*). In other words, the generated function is only based on the second network in the

`OutputNetwork`

property of `nss`

.
For more information, see `idNeuralStateSpace`

.

## Examples

## Input Arguments

## Version History

**Introduced in R2022b**

## See Also

### Objects

### Functions

`createMLPNetwork`

|`nssTrainingOptions`

|`nlssest`

|`idNeuralStateSpace/evaluate`

|`idNeuralStateSpace/linearize`

|`sim`