Hello Members,
PFA my model.
The intention of this model to delay the input signal with a configurable timer by the hardcoded delay count. My logic works fine when the input goes from 0 ->1.(able to see the out signal delayed by 2000ms), but on 1 -> 0, I am unable to see the delay between In and Out.
Anybody can point the logical error here? or help me to optimise the model using Stateflow.
Kind regards,
Joseph

 채택된 답변

Mohammed Shaheen
Mohammed Shaheen 2026년 9월 25일 6:15
Hi Joseph,
The key requirement is that while waiting, output y must remember its last accepted. Currently, the chart runs every 1 ms and InitializeOutput is enabled. Therefore:
  1. Stateflow initializes y to 0.
  2. After the delay, ACTION_St assigns y=u.
  3. ACTION_St remains active for 100 ms.
  4. When it exits, no state assigns y.
  5. Stateflow initializes y back to 0.
As a workaround, Please do the following:
  1. Open the DELAY Stateflow chart.
  2. Click the chart background and open Property Inspector.
  3. Disable Initialize outputs every time chart wakes up (InitializeOutput).
  4. Initialize the output explicitly:
INIT_St/
y = 0;
Cur_St = 0;
I hope this helps.
Thanks,
Shaheen.

추가 답변 (0개)

제품

릴리스

R2023b

태그

질문:

2026년 9월 22일 19:13

댓글:

2026년 9월 26일 21:12

Community Treasure Hunt

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

Start Hunting!

Translated by