How do I hold a value in Simulink for the rest of the simulation time?

21 ビュー (過去 30 日間)
Carlos
Carlos 2025 年 9 月 29 日 23:44
コメント済み: Mathieu NOE 2025 年 10 月 1 日 7:41
I am fairly new working with Simulink and probably I don’t know enough about the flows of information in time and how to control them.
I already read answers related to “Hold a value indefinitely once a condition becomes true”. I suppose that part of the answer could be there, but the problem is not related to a true condition keeping in time but a value that I want to keep until the end of the simulation.
I try first with a simplified system consisting of a discrete sine wave and a certain time (60 sec), I need to read the value in the vicinity of 60 sec. and propagate it until the end of the simulation time.
I tried a couple of methods, but always having the same result. I actually have the time and the value of the sine wave at which I have to propagate until the end of the simulation, but the value I have after that point is always cero.
The result of Scope 2 is:
I am expecting to have a flat line near -0.30 from 60 to 70 sec.
I you could help me with some advice it would be appreciated.

採用された回答

Mathieu NOE
Mathieu NOE 2025 年 9 月 30 日 9:15
hello
this would be my suggestion , using only a delay (or memory ) block associated with a conditionnal block
when t>= your time limit (here 6 s in my demo) the output is simply the copy of the previous value just before the time condition occured
the accuracy of the method depends of the solver options and time step used (I choose fixed time step = 1 e -3 s)
  3 件のコメント
Carlos
Carlos 2025 年 9 月 30 日 16:29
Thanks very much for your help.
Mathieu NOE
Mathieu NOE 2025 年 10 月 1 日 7:41
as always, my pleasure !
do you mind accepting my answer ? tx

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSchedule Model Components についてさらに検索

製品


リリース

R2025a

Community Treasure Hunt

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

Start Hunting!

Translated by