How to fix error in Simulink "data read before being written to" ?
58 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I get this message when I try to run my simulation of a simple elevator system. How can I fix this?
2 comentarios
Respuestas (2)
Fangjun Jiang
el 25 de Jun. de 2018
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 comentarios
Dalton L'Heureux
el 18 de Nov. de 2022
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 comentarios
Ver también
Categorías
Más información sobre Sources en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!