Main Content

系统中的样本时间

纯粹的离散系统

A purely discrete system is composed solely of discrete blocks and can be modeled using either a fixed-step or a variable-step solver. Simulating a discrete system requires that the simulator take a simulation step at every sample time hit. For a多重离散系统—a system whose blocks Simulink®样品以不同的速率 - 步骤必须发生在每个系统样本时间的整数倍数处。否则,模拟器可能会错过系统状态中的密钥过渡。Simulink软件选择的步骤大小取决于您用于金宝app模拟多条系统和基本示例时间的求解器的类型。

fundamental sample timeof a multirate discrete system is the largest double that is an integer divisor of the actual sample times of the system. For example, suppose that a system has sample times of 0.25 and 0.50 seconds. The fundamental sample time in this case is 0.25 seconds. Suppose, instead, the sample times are 0.50 and 0.75 seconds. The fundamental sample time is again 0.25 seconds.

基本示例时间的重要性直接与您指示Simulink软件使用固定步骤或可变步骤离散求解器来求解多级离散系统。金宝app固定步骤求解器设置了模拟步长等于离散系统的基本样本时间。相比之下,可变步长求解器将步长变化,等于实际样品时间命中之间的距离。

这following diagram illustrates the difference between a fixed-step and a variable-step solver.

在图中,箭头指示模拟步骤和圆圈表示样品时间命中。如图所示,如果基本样本时间小于要模拟的系统的任何实际示例时间,则可变步骤求解器需要更少的模拟步骤来模拟系统。另一方面,固定步骤求解器需要更少的内存才能实现,如果系统样本时间之一是基本的,则需要更快。这可能是需要从Simulink模型生成代码的应用程序的优势(使用金宝appSimulink Coder™)。In either case, the discrete solver provided by Simulink is optimized for discrete systems; however, you can simulate a purely discrete system with any one of the solvers and obtain equivalent results.

考虑一个简单的多条系统的以下示例。对于此示例,DTF1Discrete Transfer Fcnblock采样时间is set to[1 0.1][], which gives it an offset of0.1。这采样时间of the DTF2Discrete Transfer Fcn块设置为0.7,没有偏移。求解器设置为可变式离散求解器。

Running the simulation and plotting the outputs using the楼梯function

set_param(bdroot,'SolverType','Variable-Step','SolverName','VariableStepDiscrete','SaveFormat','Array'); simOut = sim(bdroot,'Stoptime','3'); stairs(simOut.tout,simOut.yout,'-*','LineWidth',1.2); xlabel('Time (t)'); ylabel('Outputs (out1,out2)'); legend('t_s = [1, 0.1]','t_s = 0.7','location','best')

产生以下图。

(For information on theSIMcommand. see以编程方式运行仿真。)

如图所示,因为DTF1块有一个0.1偏移,DTF1block has no output untilt = 0.1。同样,传输函数的初始条件为零。因此,在此时间之前,DTF1,Y(1)的输出为零。

混合系统

Hybrid systems同时包含离散和连续块,因此具有离散和连续状态。但是,Simuli金宝appnk求解器将任何具有连续和离散样品时间作为混合系统的系统。有关建模混合系统的信息,请参阅建模混合系统

在框图中,术语混合动力术语适用于混合系统(混合连续 - 混合系统)和具有多个样品时间(多段系统)的系统。当您执行时,此类系统变成黄色更新图带有样品时间显示Colors转身 'on'. As an example, consider the following model that contains an atomic subsystem, “Discrete Cruise Controller”, and a virtual subsystem, “Car Dynamics”. (Seeex_execution_order。)

汽车模型

With the采样时间选项设置为All, 一个更新图将虚拟子系统变成黄色,表明它是一个混合子系统。在这种情况下,子系统是一个真正的混合系统,因为它具有连续和离散的样本时间。如下所示,离散输入信号D1与连续速度信号V相结合,以产生对积分器的连续输入。

更新图后的汽车模型

Car Dynamics Subsystem after an Update Diagram

Now consider a multirate subsystem that contains three正弦波source blocks, each of which has a unique sample time — 0.2, 0.3, and 0.4, respectively.

更新图之后的多条子系统

一个更新图将子系统黄色因为子系统contains more than one sample time. As shown in the block diagram, the正弦波blocks have discrete sample times D1, D2, and D3 and the output signal is fixed in minor step.

在评估多个样本时间的系统时,Simulink不考虑常数[INF,0]或异步[–1,–N]样本时间。金宝app因此,一个由一个块组成的子系统将输出恒定值和一个具有离散样品时间的一个块组成,将不指定为混合动力。

混合注释和着色对于评估模型中的子系统是否继承了正确或预期的样本时间非常有用。

也可以看看

|