function [ a, b, c] = lint( t, x, flag, I)
% LINT: leaky integration part of leaky integrate-and-fire model
% August 1999 by K. Doya

global	v0 v1 v2 tau

if isempty( flag)	% No flag: return xdot
	% input current
	if size(I,2) == 2	% (t,I) table
		It = interp1(I(:,1),I(:,2),t);
	else			% constant
		It = I(1);
	end
	% xdot
	a = (It - x)/tau;
	return;
end

switch( flag)
case 'init'			% Initialization
	v0 = -20;		% reset level
	v1 = 0;			% threshold
	v2 = 60;		% spike
	tau = 10;		% time constant
	% return default values
	a = [0 100];	% default tspan
	b = [ v0];		% default initial value
	c = odeset( 'events','on');	% default option
case 'events'		% For zero corssing detection
	a = x - v1;		% value to be checked
	b = 1;			% terminate on crossing
	c = 1;			% on increasing direction
case 'name'			% Variable names
	a = char( 'v');
otherwise
	error( [ ' invalid option: ', flag]);
end

% end of lint.m
