outputs of generated code are NAN
显示 更早的评论
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 个)
John D'Errico
2018-6-25
编辑:John D'Errico
2018-6-25
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?
类别
在 帮助中心 和 File Exchange 中查找有关 Logical 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

