Problem with division by zero

arnaud dujeu fangorn813 at hotmail.com
Tue Jul 19 11:45:33 CEST 2011


Hi, 
I am using scilab to solve a differential equation and I have an error ("error 27") I don't understand.
When K=1 pr K>1 it's okay but as soon as K<1 there is the error.
This is my code : 
function [Xprime]=VanDerPol(t, X)
 
 Xprime(1) = X(2)
 Xprime(2) = g/R*(1-sin(X(1)))/(%pi/2-X(1))-(mu*(K)*R^2*((X(2))^2)/2)+/(R^2*mu*(%pi/2-X(1)))
 
endfunction

 t=linspace(0,4,3000); X0=[85*%pi/180;0];
 [u]=ode(X0,0,t,VanDerPol);

plot(t,u(1,:)*180/%pi,'r')
 plot(t,R*u(2,:))

And there is the Scilab message when K<1 : 
-->exec('C:\Documents and Settings\ademollerat\My Documents\accelerometre\Ecoulement\VanDerPol-2.sci', -1)
Attention: redéfinition de la fonction: VanDerPol               . Utilisez funcprot(0) pour éviter ce message

 !--error 27 
Division par zéro ...

at line       7 of function VanDerPol called by :  
 [u]=ode(X0,0,t,VanDerPol);
at line      35 of exec file called by :    
exec('C:\Documents and Settings\ademollerat\My Documents\accelerometre\Ecoulement\VanDerPol-2.sci', -1)

Maybe I have made a mistake or maybe it is a bug.
Thank you for helping me.
Best regards 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20110719/63331c5b/attachment.htm>


More information about the users mailing list