function varargout = Xchaos(t,y,flag) % % this file modelled after "help odefile" switch flag case '' % Return dy/dt = Xf(t,y). varargout{1} = Xforce(t,y); case 'events' % Return [value,isterminal,direction]. [varargout{1:3}] = events(t,y); otherwise error(['Unknown flag ''' flag '''.']); end % ------------------------------------------------------------- function step = Xforce(t,y) global par step = zeros(size(y)); step(1) = 2 + par(1)*4 *y(4)*(cos( (y(1)-y(3))))^2; step(2) = par(1)*4*y(2)*y(4)* sin(2*(y(1)-y(3))) ; step(3) = 1 + y(4)^2 + par(1)*4*y(2) *(cos( (y(1)-y(3))))^2; step(4) = - par(1)*4*y(2)*y(4)* sin(2*(y(1)-y(3))); step(1) = step(1) + par(2) *sin(y(1)); step(2) = step(2) - par(2)*y(2)*cos(y(1)); % ------------------------------------------------------------- function [value,isterminal,direction] = events(t,y) global skip value = cos(y(1)/skip); isterminal = 1; direction = -1;