Documentation

Blocks for Which Sample Time Is Not Recommended

Some blocks do not enable you to set theSample Time默认情况下参数。但是,您可以看到并设置Sample Timeparameter for these blocks in an existing model if the sample time is set to a value other than the default of-1(inherited sample time). TheSample Timeparameter is not available on certain blocks because specifying a sample time that is not-1在诸如获得,Sum, andn-D Lookup Tablecauses sample rate transition to be implicitly mixed with block algorithms. This mixing can often lead to ambiguity and confusion in Simulink®models.

In most modeling applications, you specify rates for a model on the boundary of your system instead of on a block within the subsystem. You specify the system rate from incoming signals or the rate of sampling the output. You can also decide rates for events you are modeling that enter the subsystem as trigger, function-call, or enable/disable signals. Some global variables (such as Data Store Memory blocks) might need additional sample time specification. If you want to change rate within a system, use a Rate Transition block, which is designed specifically to model rate transitions.

在将来的版本中,您可能无法在不合适的块上看到或设置此参数。

Best Practice to Model Sample Times

Use these approaches instead of setting theSample Timeparameter in the blocks where it is not appropriate:

  • Adjust your model by specifyingSample Timeonly in the blocks listed inAppropriate Blocks for the Sample Time Parameter, and setSample Timeto-1对于所有其他块。要同时更改多个块的示例时间,请使用Model Explorer。有关更多信息,请参阅Editing Object Properties.

  • Use theRate Transitionblock to model rate transitions in your model.

  • Use the信号规范block to specify sample time in models that don’t have source blocks, such as algebraic loops.

  • Specify the simulation rate independently from the block sample times, using the Model Parameter dialog box.

Once you have completed these changes, verify whether your model gives the same outputs as before.

Appropriate Blocks for the Sample Time Parameter

Specify sample time on the boundary of a model or subsystem, or in blocks designed to model rate transitions. Examples include:

  • Blocks in the Sources library

  • 水槽库中的块

  • Trigger ports (ifTrigger type被设定为function-call) and Enable ports

  • 数据存储读取和数据存储rite blocks, as the Data Store Memory block they link to might be outside the boundary of the subsystem

  • Rate Transition block

  • 信号规范block

  • 离散库中的块

  • Message Receive block

  • Function Caller block

Specify Sample Time in Blocks Where Hidden

You can specify sample time in the blocks that do not display the parameter on the block dialog box. If you specify value other than-1in these blocks, no error occurs when you simulate the model. However, a message appears on the block dialog box advising to set this parameter to-1(inherited sample time). If you promote the sample time block parameter to a mask, this parameter is always visible on the mask dialog box.

To change the sample time in this case, use theset_paramcommand. For example, select a block in the Simulink Editor and, at the command prompt, enter:

set_param(gcb,'SampleTime','2');

See Also

|||

Was this topic helpful?