MATLAB SIMULINK 7 - DEVELOPING S-FUNCTIONS Podręcznik Użytkownika Strona 100

  • Pobierz
  • Dodaj do moich podręczników
  • Drukuj
  • Strona
    / 210
  • Spis treści
  • BOOKMARKI
  • Oceniono. / 5. Na podstawie oceny klientów
Przeglądanie stron 99
3 Writing S-Functions As C-MEX files
3-56
Examples of C MEX-File S-Function Blocks
Most S-Function blocks require the handling of states, continuous or discrete.
The following sections discuss common types of systems that you can model in
Simulink with S-functions:
Continuous state
Discrete state
Hybrid
Variable step sample time
Zero crossings
Time varying continuous transfer function
All e xamples are based on the C MEX-file S-function template,
sfuntmpl.c,
and sfuntmpl.doc, which contains a discussion of the S-function template.
Example - Continuous State S-Function
The matlabroot/simulink/src/csfunc.c example shows how to model a
continuous system with states in a C MEX S-function. In continuous state
integration, there is a set of states that Simulink’s solvers integrate using the
equations:
S-functions that contain continuous states implement a state-space equation.
The output portion is placed in
mdlOutputs and the derivative portion in
mdlDerivatives. To visualize how the integration works, refer back to the
flowchart on page 3-16. The output equation above corresponds to the
mdlOutputs in the major time step. Next, the example enters the integration
sectionofthe flowchart. Here Simulink performs a number ofminor time steps
(output)
(derivative)
yf
0
tx
c
u,,()=
x
·
c
f
d
tx
c
u,,()=
x
c
(states)
uy
(input) (output)
Przeglądanie stron 99
1 2 ... 95 96 97 98 99 100 101 102 103 104 105 ... 209 210

Komentarze do niniejszej Instrukcji

Brak uwag