clear

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
cd ..
cd TanakaFig7B

file_head = 'TanakaFig7BflashpeakCa'
file_mid  = 'for'
file_tail = 'sec_AMPAR.plot'

Ca = 0:0.1:10;
duration = [0.5, 1, 5, 15, 30];
area05 = Ca .* 0.5 ./ 2; 
area1  = Ca .* 1   ./ 2;
area5  = Ca .* 5   ./ 2;
area15 = Ca .* 15  ./ 2;
area30 = Ca .* 30  ./ 2;


for j = 1:5 % duration
 for i = 1:101 % Ca2+ peak
    loadtmp = load(strcat(file_head, num2str(Ca(i)), file_mid, num2str(duration(j)), file_tail));
    AMPAR(i, j) = min(loadtmp(:,2));
 end
end

cd ..
cd TanakaFig8AwithoutNoise
    
AMPARmax = AMPAR(1, 1);
LTD = (AMPARmax - AMPAR) / AMPARmax * 100;

% v blue  0.5 sec
% s black   1 sec
% d magenta 5 sec
% o red    15 sec
% ^ green  30 sec

plot(area30, LTD(:,5), 'LineStyle','-', 'Color','g')
hold on
plot(area15, LTD(:,4), 'LineStyle','-', 'Color','r')
hold on
plot(area5, LTD(:,3), 'LineStyle','-', 'Color','m')
hold on
plot(area1, LTD(:,2), 'LineStyle','-', 'Color','k')
hold on
plot(area05, LTD(:,1), 'LineStyle','-', 'Color','b')
hold on

axis([-5 50 -5 40])
set(gca,'Tickdir','out')
box off
set(gca,'xtick',[-5 0 5 10 15 20 25 30 35 40 45 50])
set(gca,'ytick',[-5 -2.5 0 2.5 5 7.5 10 12.5 15 17.5 20 22.5 25 27.5 30 32.5 35 37.5 40])
set(gca,'XTickLabel','|0||10||20||30||40||50')
set(gca,'YTickLabel','-5||0||5||10||15||20||25||30||35||40')
xlabel('[Ca]i sec (uM s)')
ylabel('LTD (%)')
title('Ca-LTD, Fig. 8A w/o Noise')

