Error in command window

3 次查看(过去 30 天)
Khushank Singhal
Khushank Singhal 2017-12-11
评论: Guillaume 2017-12-11
In my code, I am computing a variable successively in a loop (updating it again and again). After a couple of iterations, it shows NaN.
2.0375 18.6761 1.9703 -13.3317 -1.6461 0.7139
0.6603 6.9174 2.7097 -1.0691 -0.6152 0.5390
3
1.0e+03 *
Columns 1 through 13
-0.8846 -0.0211 -0.0078 -0.0014 0.0002 0.0008 0.0009 0.0009 0.0009 0.0106 1.1095 0.0010 -0.0308
-0.0163 -0.0001 -0.0010 0.0006 0.0009 0.0010 0.0010 0.0009 0.0008 0.0011 0.0147 0.0042 0.0014
here it can be seen that at third iteration, there is some kind of error and elements have abruptly become close to zero. How can it be avoided?
  1 个评论
Stephen23
Stephen23 2017-12-11
"How can it be avoided?"
Change your code, data, or expectations.

请先登录,再进行评论。

采纳的回答

Jan
Jan 2017-12-11
Seriously? You do not show any detail of the code, but only the output values and assume, that the readers of the forum can suggest a modification?
If You Matlab code computes at first values near to 0 and afterwards NaNs, this will be the correct result of the programmed formula. Perhaps either your code contains a bug, or your expectation is wrong, that the result is non NaN.
  3 个评论
Jan
Jan 2017-12-11
"1.0e+03 * ..." means that the following values are multiplied by this factor. Matlab uses this for a more compact output to the command window, but it does not concern the data.
1.0e+03 *
3.145 876
is exactly the same as:
3145 876000
Guillaume
Guillaume 2017-12-11
You can change the way matlab displays values with the format command.
format longg
may make the display more palatable for you. Note that in no way does it change the actual values calculated by matlab, only the way they are displayed.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by