clear all
close all

fileStr(1,:) = 'Results_ESPdrifter_2010_2010wave.sim.mat';
fileStr(2,:) = 'Results_ESPdrifter_2011_2010wave.sim.mat';
fileStr(3,:) = 'Results_ESPdrifter_2011_mean99.sim.mat  ';
fileStr(4,:) = 'Results_ESPdrifter_2011_mean100.sim.mat ';
fileStr(5,:) = 'Results_ESPdrifter_2011_median99.sim.mat';
file = cellstr(fileStr);

sampleRate = 100;        %samples / second
Tdistance = 10 * sampleRate;
Tlimit = [3000 4000 5000 6000];

for i = 1:length(file)
    for j = 1:length(Tlimit)
        i
        j
        clear pks locs data;
        data = load( char(file(i)) );
        [pks, locs] = findpeaks(data.tension2, 'minpeakheight', Tlimit(j), 'minpeakdistance', Tdistance);
        
        onlyPeaks(i,j,:) = zeros(1, length(data.tension2));
        for k = 1:length(locs)
            onlyPeaks(i,j,locs(k)) = pks(k);
        end
        totalPeaks(i,j) = length(pks);
    end
end

bar(totalPeaks, 'grouped');
title('Number of Peaks > Tlimit')
xlabel('1=2010 buoy, 2=2011 buoy, 3=mean99, 4=mean100, 5 = median99')
for i=1:length(Tlimit)
    legendStr(i,:) = strcat(num2str(Tlimit(i)), ' lbf');
end
legend(legendStr);








