%
a=-195
for i=1:10
ySS=[0.5 0.5 0.5 a];
[t,x]=ode45('hhode',[0 20],ySS);
subplot(1,2,1);
if max(x(:,4))>0 && max(x(:,4))<50
    plot(t, x(:,4),'r')
    drawnow;
    hold on;
    

elseif max(x(:,4))>50
    plot(t, x(:,4),'b')
    drawnow;
    hold on;
    
else
    plot(t, x(:,4),'k')
    drawnow;
    hold on;
    
end
    title('Threshold Behavior');
    xlabel('Time (ms)');
    ylabel('Transmembrane Voltage (mV)');

subplot(1,2,2);
plot(t, x(:,3),'r')
hold on
plot(t, x(:,2),'k')
plot(t, x(:,1),'b')
legend('h','m','n');
ylim([0 1]);
hold off;

waitforbuttonpress;
a=a+20;

end
%}
%{
resting = [0.3177    0.0529    0.5962  -52];
ySS=resting;
[t,x]=ode45('hhode',[0 20],ySS);
figure
if max(x(:,4))>0 && max(x(:,4))<50
    plot(t, x(:,4),'r')
    drawnow;
    hold on;
    
elseif max(x(:,4))>50
    plot(t, x(:,4),'b')
    drawnow;
    hold on;
    
else
    plot(t, x(:,4),'k')
    drawnow;
    hold on;
end

figure;
plot(t, x(:,3),'r')
hold on
plot(t, x(:,2),'k')
plot(t, x(:,1),'b')
legend('h','m','n');
%}