# Projection

Perturb the solver's solution of a system's states to better satisfy time-invariant solution relationships

## Required

No

## Language

MATLAB^{®}

## Syntax

```
Projection(s)
```

## Arguments

`s`

Instance of

`Simulink.MSFcnRunTimeBlock`

class representing the Level-2 MATLAB S-Function block.

## Description

This method is intended for use with S-functions that model
dynamic systems whose states satisfy time-invariant relationships,
such as those resulting from mass or energy conservation or other
physical laws. The Simulink^{®} engine invokes this method at each
time step after the model's solver has computed the S-function's states
for that time step. Typically, slight errors in the numerical solution
of the states cause the solutions to fail to satisfy solution invariants
exactly. Your `Projection`

method can compensate
for the errors by perturbing the states so that they more closely
approximate solution invariants at the current time step. As a result,
the numerical solution adheres more closely to the ideal solution
as the simulation progresses, producing a more accurate overall simulation
of the system modeled by your S-function.

Your `Projection`

method's perturbations of system states must fall within
the solution error tolerances specified by the model in which the S-function is embedded.
Otherwise, the perturbations may invalidate the solver's solution. It is up to your
`Projection`

method to ensure that the perturbations meet the error
tolerances specified by the model. See Perturbing a System's States Using a Solution Invariant for a simple method
for perturbing a system's states. The following articles describe more sophisticated
perturbation methods that your `mdlProjection`

method can use.

C.W. Gear, “Maintaining Solution Invariants in the Numerical Solution of ODEs,”

*Journal on Scientific and Statistical Computing*, Vol. 7, No. 3, July 1986.L.F. Shampine, “Conservation Laws and the Numerical Solution of ODEs I,”

*Computers and Mathematics with Applications*, Vol. 12B, 1986, pp. 1287–1296.L.F. Shampine, “Conservation Laws and the Numerical Solution of ODEs II,”

*Computers and Mathematics with Applications*, Vol. 38, 1999, pp. 61–72.

## Examples

## See Also

## Version History

**Introduced in R2012b**