How to fix error in Simulink "data read before being written to" ?
59 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I get this message when I try to run my simulation of a simple elevator system. How can I fix this?
2 Commenti
Risposte (2)
Fangjun Jiang
il 25 Giu 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 Commenti
Dalton L'Heureux
il 18 Nov 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 Commenti
Vedere anche
Categorie
Scopri di più su Complex Logic in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!