How to fix error in Simulink "data read before being written to" ?
조회 수: 59 (최근 30일)
이전 댓글 표시
I get this message when I try to run my simulation of a simple elevator system. How can I fix this?
댓글 수: 2
답변 (2개)
Fangjun Jiang
2018년 6월 25일
If you don't care that much, go to Model Configuration Parameters (Ctrl+E), Diagnostics, Stateflow, Read-before-write to output in Moore chart, change the setting.
댓글 수: 0
Dalton L'Heureux
2022년 11월 18일
I know this is an old post now, but figured I'd provide an answer incase anyone else runs into this. The statemachine captured in the image defualts into the Hold state. On the next time step, the first thing the statemachine is going to do is check its first priority transition from Hold to ReadKeyboard2. This condition is "[button < 0 && position > 0]." By just looking at the chart, I can't tell how the symbols "button" and "position" have been defined, but the error is telling us that at least the "position" symbol has not been initialized at the point at which Stateflow is trying to evaluate this condition. This means the value of "position" coud be anything... something stored in the memory location of a previous simulation perhaps... an untrustworthy value in otherwords. In the chart, the "position" symbol does not get explicitly defined until the statemachine enters the RunMotor state. The fix is to simply make sure all the symbols used in the statemachine are properly initialized (whether that be done internally within, or externally to the chart doesn't matter).
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Sources에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!