Using subsystem compiled sample time parameter in executing model

3 ビュー (過去 30 日間)
Jason Muller
Jason Muller 2015 年 12 月 8 日
コメント済み: Petr75661 2021 年 9 月 20 日
Hello, I am wondering if there is any way to automatically get the CompiledSampleTime parameter for a discrete fixed-step subsystem at compilation time in Simulink, and then use the value as a constant within the model during its execution?
For example, I can get the model fundamental sample time and use it during execution in this way by inserting the line of code eval( get_param(bdroot, 'FixedStep') ); into a constant block.
Is there any similar method to get the compiled sample time of a subsystem? I thought perhaps setting the sample time of a constant block to inherited (-1), placing it inside the subsystem, and using something like eval( get_param(gcs, 'CompiledSampleTime') ); as the constant value might yield what I am looking for. But alas it does not.
Edit: This would obviously only apply to multi-rate models

採用された回答

Vaibhav Awale
Vaibhav Awale 2016 年 1 月 14 日
Hi,
Systems don't have the property called 'CompiledSampleTime'. Hence instead of 'gcs', using 'gcb' will give the required result.
get_param(gcb,'CompiledSampleTime');
However it is always better to mention the block name instead of "gcb" because "gcb" remembers the last block you had clicked on and it will output sample time of that block.
Hope this helps,
Regards,
Vaibhav
  1 件のコメント
Petr75661
Petr75661 2021 年 9 月 20 日
If the block is configured to inherit the sample time, then the function get_param(gcb,'CompiledSampleTime') is useless because it will always return -1 when blocks' callbacks are executed during the initialization phase of simulation run and code generation (tested in R2019a).

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSources についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by