主要内容

万博1manbetx子系统作为状态

By using a Simulink®subsystem within a Stateflow®state, you can model hybrid dynamic systems or systems that switch between periodic and continuous time dynamics. In your Stateflow chart, you can use Simulink based states to model a periodic or continuous dynamic system combined with switching logic that uses transitions. You can access inputs and outputs from your chart within each Simulink based state. Simulink based states are not supported in standalone Stateflow charts in MATLAB®

To initialize Simulink blocks when switching between Simulink based states, use Stateflow textual notation or Simulink State Reader and State Writer blocks.

To create linked Simulink based states, use libraries to save action subsystems. When you copy an action subsystem from a library model into a Stateflow chart, it appears as a linked Simulink based state. When you update the library block, the changes are reflected in all Stateflow charts containing the block.

使用基于Si万博1manbetxmulink的状态意味着您不必在状态流中使用复杂的文本语法来建模混合系统。

何时使用万博1manbetxBased States

Use Simulink based states when:

  • You want to model hybrid dynamic systems that include continuous or periodic dynamics.

  • 系统动力学的结构在各种操作模式之间发生了实质性变化,例如建模PID控制器。

对于您间歇性调用逻辑的系统,请使用Simulink函数。万博1manbetx

When the structure of the Simulink algorithm remains substantially unchanged, but certain gains or parameters switch between various models, use Simulink logic outside of Stateflow. An example of this type of algorithm is gain scheduling. SeeSimulink中的模型增益制定控制系统万博1manbetx(Simulink Control Design)

通过使用基于Simulink的状态模拟杆摩托克万博1manbetx

This Stateflow chart models a person moving through the stages of pole vaulting by using Simulink based states.

第一阶段是Vaulter的方法运行,该方法以基于Simulink的状态建模万博1manbetxRun_up。In the second stage, the vaulter plants the pole and takes off, which is modeled by the Simulink based stateTake_off。The final stage happens when the vaulter clears the bar and releases the pole, which is modeled by the Simulink based stateFly

美国Run_upFlyare easier to model by using Cartesian coordinates. The stateTake_off使用极坐标更容易建模。要从一个坐标系切换到另一个坐标系,请使用simulink函数万博1manbetxInitTakeOffInitFly

建模杆象光的方法

图表中的默认状态PoleVaulterRun_up。该状态模拟了杆象光沿地面向跳跃的行驶。杆沃尔特开始于-10$ x $-axis and runs toward zero. As the pole vaulter moves along the ground, the position of the pole vaulter in the xy-plane is continuously changing, but the state of running remains the same. In this model, the integrator blocks位置速度are state owner blocks for State Reader blocks in the Simulink functionInitTakeOff。该子系统输出了极沃尔特的笛卡尔坐标。

将笛卡尔坐标转换为极坐标

The transition fromRun_uptoTake_offoccurs when the position of the pole vaulter along the$ x $-axis,Run_up.p(1),变得大于-4。在过渡期间InitTakeOff是initialized, the State Reader block connects to its owner block, and the function is executed. This function converts the Cartesian coordinates from位置速度to polar coordinates,r,theta,RDOT, 和theta_dot。These coordinates are output as State Writer blocks, which are connected to owner blocks in the stateTake_off。Simu万博1manbetxlink函数InitTakeOffcontains this logic:

模拟杆子的脱落

When the position of the pole vaulter along the$ x $-axis,Run_up.p(1), becomes greater than -4, the Simulink based stateTake_off成为活跃状态。This state models the pole vaulter during the take off phase of the jump. This subsystem outputs the Cartesian coordinates of the pole vaulter.

将极地坐标转换为笛卡尔坐标

The transition fromTake_offtoFlyoccurs when the angle of the pole vaulter,theta,成为不到$ \ pi/2 $。在过渡期间,InitFly是initialized, the State Reader block connects to its owner block, and the function is executed. This function converts the polar coordinatesr,theta,RDOT, 和theta_dotto Cartesian coordinates,xy_integxydot。These coordinates are output as State Writer blocks, which are connected to owner blocks in the stateFly。Simu万博1manbetxlink函数InitFlycontains this logic:

Model the Free Fall of the Pole Vaulter

When the angle of the pole vaulter,theta, 小于$ \ pi/2 $, the Simulink based stateFly成为活跃状态。该状态在跳跃清除后对极载体建模,而杆象光却落在地面上。随着杆沃尔特的落下,X-Y平面中极沃尔特的位置正在不断变化,但落下状态保持不变。在此模型中,集成器块XYDOT和XY_INTEG是Simulink函数Initfly中国家作家块的州所有者块。万博1manbetx该子系统输出了极沃尔特的笛卡尔坐标。

记录块显示了此模拟的结果。

限制

You cannot use Simulink based states with:

  • 摩尔图表

  • Discrete Event charts

  • HDL编码器

  • PLC Coder

  • Simulink Code Inspector

  • Super step transitions

Simulink based states do not support debugging.

相关话题