close all
clear all


files = dir('*.mat');

for i = 1:length(files)
   disp(num2str(i));
   load(files(i).name);
   Hs(i) = SigWaveHeight;
   freq{i} = f;
   Pxx{i} = PxxHeave;
   
end


Means = load('.\MeanSpectras\MeanSpectra.mat');


figure('Position',[1000   420    991   1078],'PaperOrientation','portrait','PaperPosition',[0 0 8.5 11]);

for i = 2:7
   disp(['Hs: ' num2str(i) 'm -> ' num2str(i+1) 'm']); 

   idx = find((Hs < Means.edges(i+1)) & (Hs > Means.edges(i)));
   
   subplot(3,2,i-1);
   plot(Means.MeanFreq{i},Means.MeanEnergy{i}/(2*pi),'k','LineWidth',1);
   hold all
   for j = 1:length(idx)
       plot(freq{idx(j)},Pxx{idx(j)}/(2*pi),'g:','LineWidth',.2);
   end
   plot(Means.MeanFreq{i},Means.MeanEnergy{i}/(2*pi),'k','LineWidth',1);
   
   xlabel('Freq (Hz)');
   ylabel('Energy (m^2 s/rad)');
   title(['Hs = ' num2str(Means.edges(i)) 'm -> ' num2str(Means.edges(i+1)) 'm']);
   if(i<7)
     legend('Assumed Spectra','Actual 30min Spectra');
   else
     legend('Assumed Spectra');
   end
       
end

print('-dpdf','MeasuredSpectraComparedtoMayMeans');