Help: Subplot function
1 次查看(过去 30 天)
显示 更早的评论
I am trying to customize the plots in the script " hhrun - Hodgkin Huxley model simulation for user defined input current" by Rohit Chandra. The original plot function is shown below:
for i=1:loop-1
V(i+1) = V(i) + dt*(gNa*m(i)^3*h(i)*(eNa-(V(i)+65)) + gK*n(i)^4*(eK-(V(i)+65)) + gL*(eL-(V(i)+65)) + I);
m(i+1) = m(i) + dt*(alphaM(V(i))*(1-m(i)) - betaM(V(i))*m(i));
h(i+1) = h(i) + dt*(alphaH(V(i))*(1-h(i)) - betaH(V(i))*h(i));
n(i+1) = n(i) + dt*(alphaN(V(i))*(1-n(i)) - betaN(V(i))*n(i));
end
if Plot == 1
figure
plot(t,V);
xlabel('Time');
ylabel('Membrane Potential');
title('Voltage time series');
figure
plot(V,m);
xlabel('Voltage');
ylabel('m');
title('V vs. m');
figure
plot(V,n);
xlabel('Voltage');
ylabel('n');
title('V vs. n');
figure
plot(V,h);
xlabel('Voltage');
ylabel('h');
title('V vs. h');
end
However, I am trying to incorporate those plots into one figure, where plot(t,v) would be placed across the columns in the first row and the other 3 plots would be positioned in the second row and one in each column. The code below is my attempt at trying to create subplots. When I would try to run the program, nothing happens (no results and no error messages). Then, I would hit pause and the program would continuously pause forcing me to stop the execution. However, nothing happens when I would stop the execution. Please let me know if I'm missing something is wrong. Thank you!
for i=1:loop-1
V(i+1) = V(i) + dt*(gNa*m(i)^3*h(i)*(eNa-(V(i)+65)) + gK*n(i)^4*(eK-(V(i)+65)) + gL*(eL-(V(i)+65)) + I);
m(i+1) = m(i) + dt*(alphaM(V(i))*(1-m(i)) - betaM(V(i))*m(i));
h(i+1) = h(i) + dt*(alphaH(V(i))*(1-h(i)) - betaH(V(i))*h(i));
n(i+1) = n(i) + dt*(alphaN(V(i))*(1-n(i)) - betaN(V(i))*n(i));
end
if Plot == 1
figure
subplot(2,3,1:3);
plot(t,V);
xlabel('Time');
ylabel('Membrane Potential');
title('Voltage time series');
subplot(2,3,4);
plot(V,m);
xlabel('Voltage');
ylabel('m');
title('V vs. m');
subplot(2,3,5);
plot(V,n);
xlabel('Voltage');
ylabel('n');
title('V vs. n');
subplot(2,3,6);
plot(V,h);
xlabel('Voltage');
ylabel('h');
title('V vs. h');
end
1 个评论
Walter Roberson
2019-5-1
We as outsiders have no reason to expect that Plot == 1 is true.
I notice you do not have any drawnow() . However you do have figure(), which would open a new figure each time, which is defined to trigger drawing of what has been queued before that point.
回答(1 个)
imrankhan ajees
2019-5-1
you have to use the subplot function first to plot many graphs in an figure. here i am giving you an example of the subplot you want kindly make use of it..run the below code you will get the desired output.....
x=[0.2 0.5 0.8 0.99]
y=[0.1 0.3 0.5 0.7]
subplot(2,3,1)
plot(x,y)
xlabel('Voltage');
ylabel('m');
title('V vs. m');
subplot(2,3,2)
plot(x,y)
xlabel('Voltage');
ylabel('m');
title('V vs. m');
subplot(2,3,3)
plot(x,y)
xlabel('Voltage');
ylabel('m');
title('V vs. m');
subplot(2,3,4)
plot(x,y)
xlabel('Voltage');
ylabel('m');
title('V vs. m');
subplot(2,3,5)
plot(x,y)
xlabel('Voltage');
ylabel('m');
title('V vs. m');
subplot(2,3,6)
plot(x,y)
xlabel('Voltage');
ylabel('m');
title('V vs. m');
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Neural Simulation 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!