Borrar filtros
Borrar filtros

Error in command window

3 visualizaciones (últimos 30 días)
Khushank Singhal
Khushank Singhal el 11 de Dic. de 2017
Comentada: Guillaume el 11 de Dic. de 2017
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 comentario
Stephen23
Stephen23 el 11 de Dic. de 2017
"How can it be avoided?"
Change your code, data, or expectations.

Iniciar sesión para comentar.

Respuesta aceptada

Jan
Jan el 11 de Dic. de 2017
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 comentarios
Jan
Jan el 11 de Dic. de 2017
"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 el 11 de Dic. de 2017
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.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Logical en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by