Is there an example available on how to initialize the states in a C-MEX S-function via input signals?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
I would like an example on how to initialize the states in a C-MEX S-function via input signals.
Respuesta aceptada
MathWorks Support Team
el 27 de Jun. de 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 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Configure C/C++ S-Function Features en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!