outputs of generated code are NAN
Show older comments
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!
Answers (1)
John D'Errico
on 25 Jun 2018
Edited: John D'Errico
on 25 Jun 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 Comment
Categories
Find more on Logical in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
