function[]=izhikevich(varargin)
if nargin > 0
eval(varargin{1}); %execute the argument
else
main;
end;
%--------------------------------
function[]=main
global mode modeold pauseflag drawnull thresh quitflag
global a b c d I v u VU L
L = 500;
pauseflag=-1;
mode = 'A';
modeold=['0'];
drawnull=1;
quitflag=0;
pars=[0.02 0.2 -65 6 14 ;... % tonic spiking
0.02 0.25 -65 6 0.5 ;... % phasic spiking
0.02 0.2 -50 2 15 ;... % tonic bursting
0.02 0.25 -55 0.05 0.6 ;... % phasic bursting
0.02 0.2 -55 4 10 ;... % mixed mode
0.01 0.2 -65 8 30 ;... % spike frequency adaptation
0.02 -0.1 -55 6 0 ;... % Class 1
0.2 0.26 -65 0 0 ;... % Class 2
0.02 0.2 -65 6 7 ;... % spike latency
0.05 0.26 -60 0 0 ;... % subthreshold oscillations
0.1 0.26 -60 -1 0 ;... % resonator
0.02 -0.1 -55 6 0 ;... % integrator
0.03 0.25 -60 4 0;... % rebound spike
0.03 0.25 -52 0 0;... % rebound burst
0.03 0.25 -60 4 0 ;... % threshold variability
1 1.5 -60 0 -65 ;... % bistability
1 0.2 -60 -21 0 ;... % DAP
0.02 1 -55 4 0 ;... % accomodation
-0.02 -1 -60 8 80 ;... % inhibition-induced spiking
-0.026 -1 -45 0 80]; % inhibition-induced bursting
a=pars(1,1);
b=pars(1,2);
c=pars(1,3);
d=pars(1,4);
I=pars(1,5);
figNumber = figure(1);
clf;
set(figNumber,'NumberTitle','off','doublebuffer','on',...
'Name','Simple Model by Izhikevich (2003)',...
'Units','normalized','toolbar','figure',...
'Position',[0.05 0.1 0.9 0.8]);
h1=subplot(4,2,1);
set(h1,'Position',[0.05 0.75 0.27 0.2])
vtrace=line('color','k','LineStyle','-','erase','background','xdata',[],'ydata',[],'zdata',[]);
axis([0 100 -100 30])
title('membrane potential, v')
xlabel('time (ms)');
h2=subplot(4,2,3);
set(h2,'Position',[0.05 0.5 0.27 0.15])
utrace=line('color','k','LineStyle','-','erase','background','xdata',[],'ydata',[],'zdata',[]);
axis([0 100 -40 60])
title('recovery variable, u')
xlabel('time (ms)')
h3=subplot(2,2,2);
set(h3,'Position',[0.4 0.5 0.55 0.45])
head = line('color','r','Marker','.','markersize',20,'erase','xor','xdata',[],'ydata',[],'zdata',[]);
tail=line('color','k','LineStyle','-','erase','xor','xdata',[],'ydata',[],'zdata',[]);
vnull=line('color','b','LineStyle','-','erase','xor','xdata',[],'ydata',[],'zdata',[]);
unull=line('color','b','LineStyle','-','erase','xor','xdata',[],'ydata',[],'zdata',[]);
cnull=line('color','g','LineStyle',':','erase','xor','xdata',[],'ydata',[],'zdata',[]);
thresh=line('color','r','LineStyle','-','erase','xor','xdata',[],'ydata',[],'zdata',[]);
axis([-100 0 -60 40]);
title('phase portrait')
xlabel('v');ylabel('u');
if exist('izhikevich.jpg')
h=subplot(2,2,3);
set(h,'Position',[0.05 0.05 0.2 0.37])
fig1=imread('izhikevich.jpg');
B=gray; mind=20;
B(1:mind,:)=B(1:mind,:)/B(mind,1);
colormap(1-B);
imagesc(fig1);
axis off;
else
uicontrol('Style','frame', 'Units','normalized', ...
'Position',[0.04 0.05 0.22 0.37]);
disp(['Cannot find figure file <izhikevich.jpg>' 7]);
uicontrol('Style','text', 'Units','normalized', 'HorizontalAlignment','center',...
'Position',[0.05 0.28 0.17 0.02],'string',{'download picture izhikevich.jpg'});
uicontrol('Style','text', 'Units','normalized', 'HorizontalAlignment','center',...
'Position',[0.05 0.21 0.17 0.02],'string',{'or see Fig.1 in Izhikevich (2004)'});
end
uicontrol('Style','pushbutton', 'Units','normalized', ...
'Position',[0.05+0*0.2/4 0.09+4*0.37/5 0.02 0.025],...
'String','A','Callback','global mode; mode=''A'';');
uicontrol('Style','pushbutton', 'Units','normalized', ...
'Position',[0.05+1*0.2/4 0.09+4*0.37/5 0.02 0.025],...
'String','B','Callback','global mode; mode=''B'';');
uicontrol('Style','pushbutton', 'Units','normalized', ...
'Position',[0.05+2*0.2/4 0.09+4*0.37/5 0.02 0.025],...
'String','C','Callback','global mode; mode=''C'';');
uicontrol('Style','pushbutton', 'Units','normalized', ...
'Position',[0.05+3*0.2/4 0.09+4*0.37/5 0.02 0.025],...
'String','D','Callback','global mode; mode=''D'';');
uicontrol('Style','pushbutton', 'Units','normalized', ...
'Position',[0.05+0*0.2/4 0.09+3*0.37/5 0.02 0.025],...
'String','E','Callback','global mode; mode=''E'';');
uicontrol('Style','pushbutton', 'Units','normalized', ...
'Position',[0.05+1*0.2/4 0.09+3*0.37/5 0.02 0.025],...
'String','F','Callback','global mode; mode=''F'';');
uicontrol('Style','pushbutton', 'Units','normalized', ...
'Position',[0.05+2*0.2/4 0.09+3*0.37/5 0.02 0.025],...
'String','G','Callback','global mode; mode=''G'';');
uicontrol('Style','pushbutton', 'Units','normalized', ...
'Position',[0.05+3*0.2/4 0.09+3*0.37/5 0.02 0.025],...
'String','H','Callback','global mode; mode=''H'';');
uicontrol('Style','pushbutton', 'Units','normalized', ...
'Position',[0.05+0*0.2/4 0.09+2*0.37/5 0.02 0.025],...
'String','I','Callback','global mode; mode=''I'';');
uicontrol('Style','pushbutton', 'Units','normalized', ...
'Position',[0.05+1*0.2/4 0.09+2*0.37/5 0.02 0.025],...
'String','J','Callback','global mode; mode=''J'';');
uicontrol('Style','pushbutton', 'Units','normalized', ...
'Position',[0.05+2*0.2/4 0.09+2*0.37/5 0.02 0.025],...
'String','K','Callback','global mode; mode=''K'';');
uicontrol('Style','pushbutton', 'Units','normalized', ...
'Position',[0.05+3*0.2/4 0.09+2*0.37/5 0.02 0.025],...
'String','L','Callback','global mode; mode=''L'';');
uicontrol('Style','pushbutton', 'Units','normalized', ...
'Position',[0.05+0*0.2/4 0.09+1*0.37/5 0.02 0.025],...
'String','M','Callback','global mode; mode=''M'';');
uicontrol('Style','pushbutton', 'Units','normalized', ...
'Position',[0.05+1*0.2/4 0.09+1*0.37/5 0.02 0.025],...
'String','N','Callback','global mode; mode=''N'';');
uicontrol('Style','pushbutton', 'Units','normalized', ...
'Position',[0.05+2*0.2/4 0.09+1*0.37/5 0.02 0.025],...
'String','O','Callback','global mode; mode=''O'';');
uicontrol('Style','pushbutton', 'Units','normalized', ...
'Position',[0.05+3*0.2/4 0.09+1*0.37/5 0.02 0.025],...
'String','P','Callback','global mode; mode=''P'';');
uicontrol('Style','pushbutton', 'Units','normalized', ...
'Position',[0.05+0*0.2/4 0.09+0*0.37/5 0.02 0.025],...
'String','Q','Callback','global mode; mode=''Q'';');
uicontrol('Style','pushbutton', 'Units','normalized', ...
'Position',[0.05+1*0.2/4 0.09+0*0.37/5 0.02 0.025],...
'String','R','Callback','global mode; mode=''R'';');
uicontrol('Style','pushbutton', 'Units','normalized', ...
'Position',[0.05+2*0.2/4 0.09+0*0.37/5 0.02 0.025],...
'String','S','Callback','global mode; mode=''S'';');
uicontrol('Style','pushbutton', 'Units','normalized', ...
'Position',[0.05+3*0.2/4 0.09+0*0.37/5 0.02 0.025],...
'String','T','Callback','global mode; mode=''T'';');
uicontrol('Style','frame', 'Units','normalized', ...
'Position',[0.27 0.05 0.12 0.37]);
uicontrol('Style','text', 'Units','normalized