[adc,adc_header]=adcproc;
[apc,apc_header]=apcproc;

[md,nd]=size(adc);
[mp,np]=size(apc);

m=min(md,mp);
n=min(nd,np);

for i=1:m
   [j,d]=near(apc(:,1),adc(i,1),1);
   ast(i,:)=apc(j,1:n)-adc(i,1:n);
end

%plot blanks
figure(1)
plot(adc(:,1),ast(:,2),'r')
hold on
plot(adc(:,1),ast(:,3),'b')
plot(adc(:,1),ast(:,4),'k')
plot(adc(:,1),ast(:,5),'m')
plot(adc(:,1),ast(:,6),'c')
legend('2','3','4','5','6')
hold off

figure(2)
plot(adc(:,1),ast(:,7),'r')
hold on
plot(adc(:,1),ast(:,8),'b')
plot(adc(:,1),ast(:,9),'k')
plot(adc(:,1),ast(:,10),'m')
plot(adc(:,1),ast(:,11),'c')
legend('7','8','9','10','11')
hold off

figure(3)
plot(adc(:,1),ast(:,12),'r')
hold on
plot(adc(:,1),ast(:,13),'b')
plot(adc(:,1),ast(:,14),'k')
plot(adc(:,1),ast(:,15),'m')
plot(adc(:,1),ast(:,16),'c')
plot(adc(:,1),ast(:,17),'g')
legend('12','13','14','15','16','17')

hold off

figure(4)
plot(adc(:,1),ast(:,24),'r')
hold on
plot(adc(:,1),ast(:,25),'b')
plot(adc(:,1),ast(:,26),'k')
plot(adc(:,1),ast(:,27),'m')
plot(adc(:,1),ast(:,28),'c')
plot(adc(:,1),ast(:,29),'g')
legend('24','25','26','27','28','29')
hold off