%%Hodgkin-Huxley: AP terjedés:
close all;
resting = [0.3177    0.0529    0.5962  -59.9995]; %nyugalmi értékek
%first = resting;
firstpot = -20%-47; %kezdeti potenciálváltozás axon elején

N = 60;
ySS = zeros(1,N*4);
ySS(1:4:end) = resting(1);
ySS(2:4:end) = resting(2);
ySS(3:4:end) = resting(3);
ySS(4:4:end) = resting(4);
ySS(4) = firstpot;

[t,x]=ode45('hhode_parc',[0 60],ySS);
%{
figure
for i=1:N-5
    subplot(2,1,1); %fesz vltozás az axon mentén
    plot(t, x(:,(i-1)*4+4), 'r');
    title('Threshold Behavior');
    xlabel('Axon');
    ylabel('Transmembrane Voltage (mV)');
    xlim([-1 30]);
    ylim([-80,60])
    subplot(2,1,2); %ioncsatorna aktivitások
    plot(t, x(:,(i-1)*4+3),'r', t, x(:,(i-1)*4+2),'k', t, x(:,(i-1)*4+1),'b')
    legend('h: Na gate inactivity','m: K gate activity','n: Na gate activity');
    title('Ion gate activities');
    xlabel('Axon');
    ylabel('Activity');
    ylim([0 1]);
    xlim([-1 30]);
    pause(0.1);
    %waitforbuttonpress;
end
%}
%
figure;
for i = 1:length(t)
   plot(linspace(1,N,200),  interp1(1:N,x(i,4:4:4*N),linspace(1,N,200),'cubic')  );
  % ylim([-3.5 3.5])
  xlim([0, N]);
  ylim([-80, 80]);
  title(num2str(t(i)));
   pause(0.005);
%   waitforbuttonpress;
end
%}