Data was read before writing to - StateFlow transition

6 ビュー (過去 30 日間)
LostControl
LostControl 2023 年 4 月 16 日
編集済み: Altaïr 2025 年 1 月 2 日
When trying to implement the bouncing ball using differential equations and continous simulation, as described on mathworks.com, I seem to encounter an error.
If I use transition condition falling(p), as shown on mathworks.com, an error is raised:
Error:The data p was read before being written to. This error will stop the simulation.
Transition in Chart 'simple_ball_ode/Falling':
[falling(p)]
If I use a condition p<=0 instead, the error is gone and simulation runs properly.
Please see the images for clarification. I would really appreciate some help, cause I am clueless at this point.

回答 (1 件)

Altaïr
Altaïr 2025 年 1 月 2 日
編集済み: Altaïr 2025 年 1 月 2 日
The falling(p) transition condition compares the previous and current values of the variable p to return a Boolean value. The error data p was read before being written to, could arise when the previous value of the variable is not available. To address this issue, ensure that the Execute (enter) chart at initialization option is checked in the properties of the chart.
Alternatively, initializing the variable p should resolve the issue.
Here are some related links for further reading:

カテゴリ

Help Center および File ExchangeDecision Logic についてさらに検索

製品


リリース

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by