How do I get GNa(t) and Gk(t) on the same graph? On the graph there is supposed to be currents for m, n , h

1 view (last 30 days)
How do I get GNa(t) and Gk(t) on the same graph? On the graph there are supposed to be currents for m, n , h. This is for hodgkin huxley by the way, and I have them plotted separately
%%Current less than 1mA
I_add = 0.1;
tspan = 1000;
v = -65;
m = 0;
n = 0.1;
h = 1;
s0 = [v; m; n; h];
[t1,s1] = ode15s(@hodgkinhuxeqoriginal,[0 tspan], s0, [], I_add);
figure(1)
subplot(2, 2, 1)
plot(t1,s1(:,1));
xlabel('Time');
ylabel('Membrane Potential');
title('Voltage time series');
xlim([0 50]);
subplot(2, 2, 2)
plot(t1,s1(:,2));
xlabel('Voltage');
ylabel('time');
title('t vs. m');
xlim([0 50]);
subplot(2, 2, 3)
plot(t1,s1(:,3));
xlabel('Voltage');
ylabel('n');
title('t vs. n');
xlim([0 50]);
subplot(2, 2, 4)
plot(t1,s1(:,4));
xlabel('Voltage');
ylabel('h');
title('t vs. h');
xlim([0 50]);
set(gca, 'XScale','log', 'YScale','log')
function dSdt = hodgkinhuxeq(t,s0,I_add)
%Function hodgkinhuxeq
% Inputs: t - time
% I_add - input current
% v - voltage
%potentials
g_k = 36;
g_na = 120;
g_l = 0.3;
E_k = -77;
E_na = 50;
E_l = -54;
Cm = 1;
%variables
v = s0(1);
m = s0(2);
n = s0(3);
h = s0(4);
%eqs
a_m = -0.1*((v+35)/(exp(-0.1*(v+35))-1));
b_m = 4.0*exp((-v-60)/18);
a_h = 0.07*exp(-0.05*(v+60));
b_h = 1/1+exp(-0.1*(v+30));
a_n = -0.01*(v+50)/(exp(-0.1*(v+50))-1);
b_n = 0.125*exp(-0.0125*(v+60));
%dv/dt sections
K_1 = ((g_k*(n^4))*(v-E_k));
Na_1 = (g_na*(m^3)*h)*(v-E_na);
L_1 = g_l*(v-E_l);
%derivat
dVdt = (-1/Cm)*((K_1)+(Na_1)+(L_1)-I_add);
dmdt = a_m*(1-m)-b_m*m;
dhdt = a_h*(1-h)-b_h*h;
dndt = a_n*(1-n)-b_n*n;
dSdt = [dVdt; dmdt; dndt; dhdt];
end

Answers (1)

Srijith Kasaragod
Srijith Kasaragod on 25 Oct 2021
As per my understanding, the currents for 'm', 'n' and 'h' are returned by the function as s1(:,2), s1(:,3) and s1(:,4) respectively. You wish to plot them in a single figure rather than subplots. The following lines of code shows how it can be achieved:
plot(t1,s1(:,2));
hold on;
plot(t1,s1(:,3));
plot(t1,s1(:,4));
hold off;
legend('m','n','h');
'hold on' command retains current plot when adding new plots. Please refer this documentation to read more on 'hold' function.

Categories

Find more on Creating and Concatenating Matrices in Help Center and File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!