How do I increase the x-axis to make my action potentials bigger
1 view (last 30 days)
Show older comments
Nyimatoulie Cham
on 20 Oct 2021
Commented: Star Strider
on 21 Oct 2021
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');
subplot(2, 2, 2)
plot(t1,s1(:,2));
xlabel('Voltage');
ylabel('m');
title('t vs. m');
subplot(2, 2, 3)
plot(t1,s1(:,3));
xlabel('Voltage');
ylabel('n');
title('t vs. n');
subplot(2, 2, 4)
plot(t1,s1(:,4));
xlabel('Voltage');
ylabel('h');
title('t vs. h');
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
0 Comments
Accepted Answer
Star Strider
on 20 Oct 2021
The X-limits need to be reduced in order to show the detail, and the last subplot needs to have its axes rescaled to show the detail.
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);
[t1,s1] = ode15s(@hodgkinhuxeq,[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('m');
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
.
4 Comments
Star Strider
on 21 Oct 2021
Use the hold function or yyaxis depending on the desired result (the log scales are necessary in order to correctly show ‘h’) —
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);
[t1,s1] = ode15s(@hodgkinhuxeq,[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('m');
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')
figure
plot(t1,s1(:,4)); % Plot 'h'
hold on
plot(t1,s1(:,2)); % Plot 'm'
hold off
xlabel('Voltage');
% ylabel('h');
% title('t vs. h');
xlim([0 50])
set(gca, 'XScale','log', 'YScale','log')
legend('h','m', 'Location','best') % Add 'legend' Object
title('Using ‘hold’')
figure
yyaxis left
plot(t1,s1(:,4)); % Plot 'h'
ylabel('h')
set(gca, 'YScale','log')
yyaxis right
plot(t1,s1(:,2)); % Plot 'm'
xlabel('Voltage');
ylabel('m');
% title('t vs. h');
xlim([0 50])
set(gca, 'XScale','log')
title('Using ‘yyaxis’')
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
.
More Answers (0)
See Also
Categories
Find more on MATLAB Compiler in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!