フィルターのクリア

How to simulate simulink model in a given set of time-points only?

9 ビュー (過去 30 日間)
Vinayak Dan
Vinayak Dan 2020 年 3 月 23 日
編集済み: Birdman 2020 年 3 月 23 日
I have a set of time-points in an array and I want the simulink model to run only in the given time-stamps.
The timestep is non-uniform.

回答 (1 件)

Birdman
Birdman 2020 年 3 月 23 日
Yes, it is possible. Consider the attached Simulink model which contains a ramp block and its slope parameter is set as 5. Its stop time is 10. We expect to see the output of the ramp at t=0,1,6,9. Run the following code from command line:
t=[0 1 6 9];
y=sim('Rampout',t);
y.RampOut.Signals.Values
The last line will give you 0,5, 30 and 45 which shows that the model is ran at specified time values. You can adapt this to your application.
  4 件のコメント
Vinayak Dan
Vinayak Dan 2020 年 3 月 23 日
What I meant is that the simulation should happen only at those timestamps. At other time points I want it to hold the previous value.
Birdman
Birdman 2020 年 3 月 23 日
編集済み: Birdman 2020 年 3 月 23 日
Ok then. Try the following code with the attached modified Simulink model:
y=sim('Rampout','StartTime','0','StopTime','0')
y.Rampout.signals.values
y=sim('Rampout','StartTime','1','StopTime','1')
y.Rampout.signals.values
y=sim('Rampout','StartTime','6','StopTime','6')
y.Rampout.signals.values
y=sim('Rampout','StartTime','9','StopTime','9')
y.Rampout.signals.values
If you run each pair of line respectively, you will see the previous results that we obtained.

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

カテゴリ

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

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by