samedi 31 janvier 2015

octave ode45 'events' error


Vote count:

0




I am running code in Octave that uses the odepkg 0.8.4. The first .m file called 'poin2.m' is used for getting a Poincare plot. The ode45 command in this file calls the 'spp.m' function.



clc;clear;
OMEG=1.02;
trans=2000;
N=2000;
xfin=zeros(N+1,2);
options=odeset('RelTol',1e-9,'AbsTol',1e-9,'events','on');
xin=0.2;
xdin=-0.2;
for i=1:trans
if rem(i,50)==0
disp(i);
end
[t,x,te,xe,ie]=ode45('spp',[0 2*pi/OMEG],[xin xdin],options);
xin=x(end,1);
xdin=x(end,2);
end
xfin(1,1)=xin;
xfin(1,2)=xdin;
disp('Steady state starts');
for i=1:N
if rem(i,50)==0
disp(i);
end
[t,x,te,xe,ie]=ode45('spp',[0 2*pi/OMEG],[xin xdin],options);

xin=x(end,1);
xdin=x(end,2);
xfin(i+1,1)=x(end,1);
xfin(i+1,2)=x(end,2);
end


The function 'spp.m' contains the piecewise linear ODE to be integrated along with the required 'events' function.



function [xdot,isterminal,dircn]=spp(t,x,flag)
omega=1.02;
alpha=-0.01;q0=0.01;zhi=0.07;epsilon1=0.7;epsilon2=0.005;%epsilon2=0;temp=1;
if nargin<3 || isempty(flag)
if x(1)>1
fh=x(1)-(1-alpha);
elseif x(1)<-1
fh=x(1)+(1-alpha);
else
fh=alpha*x(1);
end
xdot=[x(2);-2*zhi*x(2)-(1+2*epsilon2*cos(omega*t))*fh+q0+(omega^2)*epsilon1*cos(omega*t);];
else
switch flag
case 'events'
xdot=x(1)^2-1;
isterminal=0;
dircn=0;
otherwise
error('function not programmed');
end;
end;


The code runs well in MATLAB but in Octave the following error shows up:



error: Unknown parameter name "events"
error: called from:
error: C:\Software\Octave-3.6.4\share\octave\packages\odepkg-0.8.4\odepkg_stru
cture_check.m at line 308, column 11
error: C:\Software\Octave-3.6.4\share\octave\packages\odepkg-0.8.4\odeset.m at
line 104, column 10
error: C:\Software\Octave-3.6.4\share\octave\packages\odepkg-0.8.4\poin2.m at
line 12, column 8


Line 12 in 'poin2.m' is actually Line 6 in the first code that is posted. I have searched a lot for this problem in 'events' but did not find a solution. Can someone help me out?



asked 57 secs ago







octave ode45 'events' error

Aucun commentaire:

Enregistrer un commentaire