clear

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
file_head = 'TanakaFig9AflashpeakCa'
file_mid  = 'for'
file_tail = 'sec_AMPAR.plot'

Ca = 0:0.1:10;
duration = [0.5, 1, 5, 15, 30];

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

    
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(Ca, LTD(:,5), 'LineStyle','-', 'Color','g')
hold on
plot(Ca, LTD(:,4), 'LineStyle','-', 'Color','r')
hold on
plot(Ca, LTD(:,3), 'LineStyle','-', 'Color','m')
hold on
plot(Ca, LTD(:,2), 'LineStyle','-', 'Color','k')
hold on
plot(Ca, LTD(:,1), 'LineStyle','-', 'Color','b')
hold on

axis([-0.5 6 -5 40])
set(gca,'Tickdir','out')
box off
set(gca,'xtick',[-0.5 0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5 5.5 6])
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||1||2||3||4||5||6')
set(gca,'YTickLabel','-5||0||5||10||15||20||25||30||35||40')
xlabel('[Ca]i (uM)')
ylabel('LTD (%)')
title('Ca-LTD, Fig. 9A w/o Noise')

save('Fig9AwitoutNoise.txt','LTD','-ASCII')

