% plot transients of Ca, IP3, IP3Ropen, IP3Rinh, and CaStore

clear
IP3Rconc = 0.26667

% Including GENESIS plot files to MATLAB

Ca(:,1:2) = load('PFalone_Ca.plot');
Ca(:,3:4) = load('CFalone_Ca.plot');
Ca(:,5:6) = load('PFCF_Ca.plot');

IP3(:,1:2) = load('PFalone_IP3.plot');
IP3(:,3:4) = load('CFalone_IP3.plot');
IP3(:,5:6) = load('PFCF_IP3.plot');

IP3Ropen(:,1:2) = load('PFalone_openIP3R.plot');
IP3Ropen(:,3:4) = load('CFalone_openIP3R.plot');
IP3Ropen(:,5:6) = load('PFCF_openIP3R.plot');

CaStore(:,1:2) = load('PFalone_CaStore.plot');
CaStore(:,3:4) = load('CFalone_CaStore.plot');
CaStore(:,5:6) = load('PFCF_CaStore.plot');

IP3Rinact(:,1:2) = load('PFalone_inactIP3R.plot');
IP3Rinact(:,3:4) = load('CFalone_inactIP3R.plot');
IP3Rinact(:,5:6) = load('PFCF_inactIP3R.plot');


IP3Ropen(:,2) = IP3Ropen(:,2) / IP3Rconc * 100;
IP3Ropen(:,4) = IP3Ropen(:,4) / IP3Rconc * 100;
IP3Ropen(:,6) = IP3Ropen(:,6) / IP3Rconc * 100;

IP3Rinact(:,2) = IP3Rinact(:,2) / IP3Rconc * 100;
IP3Rinact(:,4) = IP3Rinact(:,4) / IP3Rconc * 100;
IP3Rinact(:,6) = IP3Rinact(:,6) / IP3Rconc * 100;

time = -0.5:0.001:1.5

% plot Ca
subplot(1, 2, 1)
plot(time,Ca(:,2),'g', time,Ca(:,4),'r', time,Ca(:,6),'b')
axis([-0.1 1.05 0 10])
set(gca,'xtick',[0 0.2 0.4 0.6 0.8 1])
set(gca,'ytick',[0 1 2 3 4 5 6 7 8 9 10])
set(gca,'Tickdir','out')
box off
xlabel('Time (s)')
ylabel('[Ca2+]i (\muM)')

%plot IP3
subplot(2, 4, 3)
plot(time,IP3(:,2),'g', time,IP3(:,4),'r', time,IP3(:,6),'b')
axis([-0.1 1.05 0 5])
set(gca,'xtick',[0 0.2 0.4 0.6 0.8 1])
set(gca,'ytick',[0 1 2 3 4 5])
set(gca,'Tickdir','out')
box off
xlabel('Time (s)')
ylabel('[IP3] (\muM)')


%plot IP3Ropen
subplot(2, 4, 4)
plot(time,IP3Ropen(:,2),'g', time,IP3Ropen(:,4),'r', time,IP3Ropen(:,6),'b')
axis([-0.1 1.05 0 100])
set(gca,'xtick',[0 0.2 0.4 0.6 0.8 1])
set(gca,'ytick',[0 20 40 60 80 100])
set(gca,'Tickdir','out')
box off
xlabel('Time (s)')
ylabel('IP3R opening (%)')

%plot CaStore
subplot(2, 4, 7)
plot(time,CaStore(:,2),'g', time,CaStore(:,4),'r', time,CaStore(:,6),'b')
axis([-0.1 1.05 0 200])
set(gca,'xtick',[0 0.2 0.4 0.6 0.8 1])
set(gca,'ytick',[0 50 100 150 200])
set(gca,'Tickdir','out')
box off
xlabel('Time (s)')
ylabel('[Ca2+]ER (\muM)')


%plot IP3Rinact
subplot(2, 4, 8)
plot(time,IP3Rinact(:,2),'g', time,IP3Rinact(:,4),'r', time,IP3Rinact(:,6),'b')
axis([-0.1 1.05 0 100])
set(gca,'xtick',[0 0.2 0.4 0.6 0.8 1])
set(gca,'ytick',[0 20 40 60 80 100])
set(gca,'Tickdir','out')
box off
xlabel('Time (s)')
ylabel('IP3R inactivated (%)')