フィルターのクリア

Get simulation time in a Simulink model

4 ビュー (過去 30 日間)
Stephen
Stephen 2011 年 8 月 20 日
How do I get the simulation time for a Simulink model?
I have a Simulink model that includes a MATLAB fnc block. But I want that MATLAB fnc block to execute the primary code only once every second; not every time the fnc block receives an input.
For now, as a klutzy workaround, I have a 1 second pulse generator that is fed to the MATLAB fnc block. The MATLAB fnc block then has code to detect a rising edge. The MATLAB fnc block then only executes its code at the rising edge of the input pulse.
But I'd like to use something other than the pulse generator, for example, test when the simulation time increases by a second.

回答 (3 件)

Stephen
Stephen 2011 年 8 月 22 日
Another method is to set the sample time to one second in the subsystem paramaters dialog for the MATLAB Fnc subsystem block.

Fangjun Jiang
Fangjun Jiang 2011 年 8 月 20 日
Using the pulse generator is the right approach. You could put your MATLAB fcn block inside a triggered subsystem block so you don't have to read the pulse and decide when to run. The triggered subsystem takes care of all that.

TAB
TAB 2011 年 8 月 22 日
Solution mentioned above (by Jiang) is one approach, also you can set the 'trigger-type' of trigger block to 'function call' inside the triggered subsystem and use a function call generator to activate the subsystem at fixed intervals.

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by