- Any arithmetic operation on a NaN, such as sqrt(NaN)
- Addition or subtraction, such as magnitude subtraction of infinities as (+Inf)+(-Inf)
- Multiplication, such as 0*Inf
- Division, such as 0/0 and Inf/Inf
- Remainder, such as rem(x,y) where y is zero or x is infinity
My final output matrix contains NaN values
24 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I have written a code where there are 100 iterations, and at the end I get a matrix (14680*101). for some strange reason, some elements of this matrix are NaN. The simulation ran fine, no error message in matlab, and it didn't stop. Does anyone have any idea what this means? an row example: Iteration1.........Iteration 35 Iteration 36.........Iteration 100 Row1: 12.21121...........35.546654799912 NaN ( from this point and on, they are all NaN)
1 comentario
Stephen23
el 8 de Feb. de 2016
You need to check the calculation. NaN's do not mean "error", they mean that the result of a calculation is not defined. Check for divide-by-zero, multiply by infinity, etc. The nan documentation lists all of the things you need to check for:
Respuestas (1)
Walter Roberson
el 8 de Feb. de 2016
We need to see the code.
If you have a loop in which one iteration depends on the previous value then it is almost certain that as soon as one Nan is produced that everything else will be nan.
You get nan from 0/0 or 0*infinity. Do you have log of an exponential value? Too large of an exponent would lead to infinity and log cannot recover the original exponent when that happens.
2 comentarios
Walter Roberson
el 8 de Feb. de 2016
Would you consider showing us the code instead of vaguely describing it?
Ver también
Categorías
Más información sobre Logical en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!