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

0 投票

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.

1 件のコメント

Joseph Stalin
Joseph Stalin 2026 年 9 月 26 日 21:12
Thanks Mohammed. It working now

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File Exchange で Decision Logic についてさらに検索

製品

リリース

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