Is there an example available on how to initialize the states in a C-MEX S-function via input signals?
1 view (last 30 days)
Show older comments
I would like an example on how to initialize the states in a C-MEX S-function via input signals.
Accepted Answer
MathWorks Support Team
on 27 Jun 2009
Following is an example showing how to initialize the states in a C-MEX S-function via input signals in Simulink.
In this example the Van der Pol equations are used. To initialize the two states x1 and x2 in the equations via input signals the mdlInitializeConditions has been used. If you open up the S-function source file, you will notice the following lines in mdlInitializeConditions:
real_T *x = ssGetContStates(S);
InputRealPtrsType uPtrs0 = ssGetInputPortRealSignalPtrs(S,0);
InputRealPtrsType uPtrs1 = ssGetInputPortRealSignalPtrs(S,1);
/* init x1 */
x[0] = *uPtrs0[0];
/* init x2 */
x[1] = *uPtrs1[0];
Here at the beginning of simulation the input signals *uPtrs0 and *uPtrs1 are assigned to the states x1 and x2.
0 Comments
More Answers (0)
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!