% show some raw data
clear
IP3Rconc   = 0.26667
filelength = 100000
filenum  = 11
Calow        = zeros(filelength, filenum);
Camid        = zeros(filelength, filenum);
Cahi         = zeros(filelength, filenum);
IP3Rinactlow = zeros(filelength, filenum);
IP3Rinactmid = zeros(filelength, filenum);
IP3Rinacthi  = zeros(filelength, filenum);
tempload     = zeros(filelength, 2);

set(0,'DefaultLineLineWidth',1);

linecolor = [0,   0,   0;    %black
             0.5, 0,   0.5;  %violet
             0,   0,   1;    %blue
             0,   1,   1;    %cyan
             0,   0.5, 0;    %dark green
             0,   1,   0;    %light green
             1,   1,   0;    %yellow
             1,   0.5, 0;    %orange
             1,   0,   0;    %red
             1,   0,   1;    %magenta
             1,   0.5, 1];   %pink

%CaInflux = [0,  2020,  5260,  8273, 10547, 12238, 13542, 14597, 15490, 16278, 16999; % [IP3] = 0.1 uM
%            0,  1691,  4697,  7627,  9866, 11537, 12827, 13871, 14754, 15532, 16243; % [IP3] = 2.5 uM
%            0,  1275,  4173,  7106,  9349, 11023, 12316, 13361, 14246, 15027, 15740];% [IP3] =  10 uM
        
        
%load Ca transient
for i = 1:11
    tempload = load(strcat('trajectory_IP30.1Ca', num2str(i-1), '_Ca.plot'));
    CaIPlow(:, i) = tempload(:,2);
end
%load IP3Rinact transient
for i = 1:11
    tempload = load(strcat('trajectory_IP30.1Ca', num2str(i-1), '_IP3Rinact.plot'));
    IP3RinactIPlow(:, i) = tempload(:,2) / IP3Rconc * 100;
end

%load Ca transient
for i = 1:11
    tempload = load(strcat('trajectory_IP32.5Ca', num2str(i-1), '_Ca.plot'));
    CaIPmid(:, i) = tempload(:,2);
end
%load IP3Rinact transient
for i = 1:11
    tempload = load(strcat('trajectory_IP32.5Ca', num2str(i-1), '_IP3Rinact.plot'));
    IP3RinactIPmid(:, i) = tempload(:,2) / IP3Rconc * 100;
end

%load Ca transient
for i = 1:11
    tempload = load(strcat('trajectory_IP310Ca', num2str(i-1), '_Ca.plot'));
    CaIPhi(:, i) = tempload(:,2);
end
%load IP3Rinact transient
for i = 1:11
    tempload = load(strcat('trajectory_IP310Ca', num2str(i-1), '_IP3Rinact.plot'));
    IP3RinactIPhi(:, i) = tempload(:,2) / IP3Rconc * 100;
end

%load comon time
time    = tempload(:,1) - 0.5;
timelow = time - 0.75;
timemid = time - 0.70;
timehi  = time - 0.60;


subplot(2,3,1)
for i = 11:-1:1
plot(time(4501:7000),CaIPlow(4501:7000,i), 'Color',linecolor(i,:))
hold on
end
axis([-0.05 0.45 0 50])
set(gca,'xtick',[0 0.1 0.2])
set(gca,'XTickLabel','0|0.1|')
set(gca,'ytick',[0 5 10])
set(gca,'YTickLabel','0||10')
set(gca,'Tickdir','out')
box off
xlabel('Time (s)')
ylabel('[Ca2+] (\muM)')

subplot(2,3,2)
for i = 11:-1:1
plot(time(4501:7500),CaIPmid(4501:7500,i), 'Color',linecolor(i,:))
hold on
end
axis([-0.05 0.45 0 50])
set(gca,'xtick',[0 0.1 0.2 0.25 0.3])
set(gca,'XTickLabel','0|0.1|0.2|')
set(gca,'ytick',[0 5 10 15 20 25 30])
set(gca,'YTickLabel','0||10||20||30')
set(gca,'Tickdir','out')
box off
xlabel('Time (s)')
ylabel('[Ca2+] (\muM)')

subplot(2,3,3)
for i = 11:-1:1
plot(time(4501:8500),CaIPhi(4501:8500,i), 'Color',linecolor(i,:))
hold on
end
axis([-0.05 0.45 0 50])
set(gca,'xtick',[0 0.1 0.20 0.25 0.3 0.4])
set(gca,'XTickLabel','0|0.1|0.2|0.3|')
set(gca,'ytick',[0 5 10 15 20 25 30 35 40 45 50])
set(gca,'YTickLabel','0||10||20||30||40||50')
set(gca,'Tickdir','out')
box off
xlabel('Time (s)')
ylabel('[Ca2+] (\muM)')


subplot(2,3,4)
for i = 11:-1:1
plot(time(4501:7000),     IP3RinactIPlow(4501:7000,i), 'Color',linecolor(i,:))
hold on
plot(timelow(14501:15500),IP3RinactIPlow(14501:15500,i), 'Color',linecolor(i,:))
end
axis([-0.05 0.45 0 100])
set(gca,'xtick',[0 0.1 0.2 0.25 0.3])
set(gca,'XTickLabel','0|0.1||1|')
set(gca,'ytick',[0 20 40 60 80 100])
set(gca,'Tickdir','out')
box off
xlabel('Time (s)')
ylabel('IP3R inactivated (%)')

subplot(2,3,5)
for i = 11:-1:1
plot(time(4501:7500),     IP3RinactIPmid(4501:7500,i), 'Color',linecolor(i,:))
hold on
plot(timemid(14501:15500),IP3RinactIPmid(14501:15500,i), 'Color',linecolor(i,:))
end
axis([-0.05 0.45 0 100])
set(gca,'xtick',[0 0.1 0.2 0.25 0.3 0.35])
set(gca,'XTickLabel','0|0.1|0.2||1|')
set(gca,'ytick',[0 20 40 60 80 100])
set(gca,'Tickdir','out')
box off
xlabel('Time (s)')
ylabel('IP3R inactivated (%)')

subplot(2,3,6)
for i = 11:-1:1
plot(time(4501:8500),     IP3RinactIPhi(4501:8500,i), 'Color',linecolor(i,:))
hold on
plot(timehi(14501:15500),IP3RinactIPhi(14501:15500,i), 'Color',linecolor(i,:))
end
axis([-0.05 0.45 0 100])
set(gca,'xtick',[0 0.1 0.2 0.3 0.35 0.4])
set(gca,'XTickLabel','0|0.1|0.2|0.3||1|')
set(gca,'ytick',[0 20 40 60 80 100])
set(gca,'Tickdir','out')
box off
xlabel('Time (s)')
ylabel('IP3R inactivated (%)')