outputs of generated code are NAN
Mostrar comentarios más antiguos
Hello, I did code generation of PD Controller. And when I set inputs(thetad, phid, psid, zd), I always get NAN in outputs. Who has similar situation?
Thanks!
1 comentario
Rui Shi
el 26 de Jun. de 2018
Respuestas (1)
John D'Errico
el 25 de Jun. de 2018
Editada: John D'Errico
el 25 de Jun. de 2018
The crystal ball is so foggy today. Strange, because it is a nice, sunny day here.
Sorry, but we cannot read your mind, nor can we see into your computer. So how can we know what silly thing you did that generated a NaN? There are lots of ways to create a NaN.
Here are a few common ways to generate a NaN. I recall there are quite a few more ways NaN can result.
0/0
ans =
NaN
inf - inf
ans =
NaN
inf/inf
ans =
NaN
So a NaN results when there is an arithmetic operation with a result that is indeterminate. So while inf+inf just creates another inf, inf-inf is something that arguably could be any value.
And of course, many operations that have a NaN as one of the arguments will result in a NaN. So once you have one NaN, they often propagate, like rabbits.
NaN + 1
ans =
NaN
So, you want to learn about the debugger. You can set it to stop when it sees a problem arise.
dbstop if infnan
Then you need to look at the line in question. What did you do that caused this event?
1 comentario
Categorías
Más información sobre Logical en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

