Is there an example available on how to initialize the states in a C-MEX S-function via input signals?
3 ビュー (過去 30 日間)
古いコメントを表示
I would like an example on how to initialize the states in a C-MEX S-function via input signals.
採用された回答
MathWorks Support Team
2009 年 6 月 27 日
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 件のコメント
その他の回答 (0 件)
参考
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!