load('SCRN0420.TXT');
load('SCRN0421.TXT');
load('SCRN0422.TXT');
load('SCRN0423.TXT');
load('SCRN0425.TXT');
load('SCRN0426.TXT');
load('SCRN0427.TXT');
load('SCRN0428.TXT');
load('SCRN0429.TXT');
load('SCRN0103.TXT');
load('SCRN0104.TXT');
load('SCRN0105.TXT');
load('SCRN0106.TXT');
load('SCRN0107.TXT');
load('SCRN0108.TXT');
load('SCRN0109.TXT');



EX_PDH_NoiseSpecV_PLLBoost1Off_PDHBoost2Off(:,1) = vertcat(SCRN0423(:,1),SCRN0422(100:800,1),SCRN0421(100:800,1),SCRN0420(100:800,1));
EX_PDH_NoiseSpecV_PLLBoost1Off_PDHBoost2Off(:,2) = vertcat(SCRN0423(:,2),SCRN0422(100:800,2),SCRN0421(100:800,2),SCRN0420(100:800,2)); 
EX_PDH_NoiseSpecV_PLLBoost1Off_PDHBoost2On(:,1) = vertcat(SCRN0428(:,1),SCRN0427(100:800,1),SCRN0426(100:800,1),SCRN0425(100:800,1));
EX_PDH_NoiseSpecV_PLLBoost1Off_PDHBoost2On(:,2) = vertcat(SCRN0428(:,2),SCRN0427(100:800,2),SCRN0426(100:800,2),SCRN0425(100:800,2)); 
EX_PDH_NoiseSpecV_PLLBoost1On_PDHBoost2Off(:,1) = vertcat(SCRN0105(:,1),SCRN0104(100:800,1),SCRN0103(100:800,1),SCRN0429(100:800,1));
EX_PDH_NoiseSpecV_PLLBoost1On_PDHBoost2Off(:,2) = vertcat(SCRN0105(:,2),SCRN0104(100:800,2),SCRN0103(100:800,2),SCRN0429(100:800,2)); 
EX_PDH_NoiseSpecV_PLLBoost1On_PDHBoost2On(:,1) = vertcat(SCRN0109(:,1),SCRN0108(100:800,1),SCRN0107(100:800,1),SCRN0106(100:800,1));
EX_PDH_NoiseSpecV_PLLBoost1On_PDHBoost2On(:,2) = vertcat(SCRN0109(:,2),SCRN0108(100:800,2),SCRN0107(100:800,2),SCRN0106(100:800,2)); 

data(:,:,1)=EX_PDH_NoiseSpecV_PLLBoost1Off_PDHBoost2Off;
data(:,:,2)=EX_PDH_NoiseSpecV_PLLBoost1Off_PDHBoost2On;
data(:,:,3)=EX_PDH_NoiseSpecV_PLLBoost1On_PDHBoost2Off;
data(:,:,4)=EX_PDH_NoiseSpecV_PLLBoost1On_PDHBoost2On;
for i=1:4
    rms(:, i)=[(-1.*cumtrapz(flipud(data(:,1, i)), flipud(data(:, 2,i)).^2)).^(0.5)]';
end
rms=flipud(rms);
freq=data(:,1,1);

figure(2)
clf;
loglog(EX_PDH_NoiseSpecV_PLLBoost1Off_PDHBoost2Off(:,1), EX_PDH_NoiseSpecV_PLLBoost1Off_PDHBoost2Off(:,2),...
    EX_PDH_NoiseSpecV_PLLBoost1Off_PDHBoost2On(:,1),EX_PDH_NoiseSpecV_PLLBoost1Off_PDHBoost2On(:,2),...
    EX_PDH_NoiseSpecV_PLLBoost1On_PDHBoost2Off(:,1), EX_PDH_NoiseSpecV_PLLBoost1On_PDHBoost2Off(:,2),...
    EX_PDH_NoiseSpecV_PLLBoost1On_PDHBoost2On(:,1), EX_PDH_NoiseSpecV_PLLBoost1On_PDHBoost2On(:,2),...
    freq, rms(:,2))
grid on;
title('PDH Error Signal');
xlabel('Frequency [Hz]');
ylabel('Amplitude Spectrum [Vrms/SqrtHz]');
legend('PLL Boost 1 Off, PDH Boost 2 Off',...
    'PLL Boost 1 Off, PDH Boost 2 On',...
    'PLL Boost 1 On, PDH Boost 2 Off',...
    'PLL Boost 1 On, PDH Boost 2 On',...
    'RMS PLL Boost 1 Off, PDH Boost 2 On', 'Location', 'SouthEast');
set(gcf, 'Color', 'w');

saveas(gcf, '/Users/alexastaley/Documents/Matlab/EX_PDH_DATA/PDH Error Sig.pdf');

save('/Users/alexastaley/Documents/MATLAB/EX_PLL_DATA/EX_PDH_NoiseSpecV_PLLBoost1Off_PDHBoost2Off.txt','EX_PDH_NoiseSpecV_PLLBoost1Off_PDHBoost2Off', '-ascii');
save('/Users/alexastaley/Documents/MATLAB/EX_PLL_DATA/EX_PDH_NoiseSpecV_PLLBoost1Off_PDHBoost2On.txt','EX_PDH_NoiseSpecV_PLLBoost1Off_PDHBoost2On', '-ascii');
save('/Users/alexastaley/Documents/MATLAB/EX_PLL_DATA/EX_PDH_NoiseSpecV_PLLBoost1On_PDHBoost2Off.txt','EX_PDH_NoiseSpecV_PLLBoost1On_PDHBoost2Off', '-ascii');
save('/Users/alexastaley/Documents/MATLAB/EX_PLL_DATA/EX_PDH_NoiseSpecV_PLLBoost1On_PDHBoost2On.txt','EX_PDH_NoiseSpecV_PLLBoost1On_PDHBoost2On', '-ascii');