Error in command window
조회 수: 3 (최근 30일)
이전 댓글 표시
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
채택된 답변
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
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
2017년 12월 11일
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 Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!