Error using griddedInterpolant. The coordinates of the input points must be finite values; Inf and NaN are not permitted.
    10 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
I am trying to solve a System of differential equations for a torsional pendulum with euler forward finite difference method. (lines 37 to 51) After every step I need to find an specific value of time (tn) by interpolation with the angular position y(1,:) and the time t (lines 59 to 65). It works most of the time but for some values of final time tf it gives me the following error:
Error using griddedInterpolant. The coordinates of the input points must be finite values; Inf and NaN are not permitted.
I can see that the value PHIt_tn= (y(1,i+1))-(2*pi/N) is resulting to be NaN but I don't understand why or how to fix it. Some values of final time (tf) that give me error are: 59,48,64 and up. I can also see that in these cases the values ydot turn into NaN (really don't know why because all the vectors that operate to create ydot are real numbers).
2 comentarios
  Satyajeet Sasmal
    
 el 16 de Nov. de 2015
				Looks like you might have either/some/all of the conditions given below:
1.Any arithmetic operation on a NaN, such as sqrt(NaN)
2.Addition or subtraction, such as magnitude subtraction of infinities as (+Inf)+(-Inf)
3.Multiplication, such as 0*Inf
4.Division, such as 0/0 and Inf/Inf
5.Remainder, such as rem(x,y) where y is zero or x is infinity
All of the above scenarios can give a NaN.
You could give conditions in your code to test against the above conditions and only proceed with further calculations after being sure that there are no NaNs.
  Walter Roberson
      
      
 el 16 de Nov. de 2015
				At the MATLAB command line, give the command
dbstop if naninf
and run your code. It will stop in the debugger as soon as it finds a NaN or infinity being generated in your code. You can then examine the commands and the data to figure out why they are happening. Infinities often quickly lead to NaN.
Respuestas (0)
Ver también
Categorías
				Más información sobre Interpolation of 2-D Selections in 3-D Grids en Help Center y File Exchange.
			
	Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


