
for i=2:5,
    if i<10
    fileName=strcat('BED0000',int2str(i),'.EVT.OUT');
    processBEDData(fileName);
    elseif i<100&& i>=10
    fileName=strcat('BED000',int2str(i),'.EVT.OUT');
    processBEDData(fileName);
    else
       fileName=strcat('BED00',int2str(i),'.EVT.OUT');
    processBEDData(fileName);
    end
end

close all;
clear all;
DeployData=[];

for i=38:40,
    if i<10
    fileName=strcat('BED0000',int2str(i),'_EVT.mat');
   load(fileName);
    DeployData=[DeployData;AllData];
    elseif i<100&& i>=10
   fileName=strcat('BED000',int2str(i),'_EVT.mat');
   load(fileName);
  DeployData=[DeployData;AllData];
    elseif i > 100
   fileName=strcat('BED00',int2str(i),'_EVT.mat');
   load(fileName);
  DeployData=[DeployData;AllData];
    else
       
    end
  
end

euler=[];
 euler=quatern2euler(quaternConj(DeployData(:,5:8))); % use conjugate for sensor frame relative to Earth

figure('Name', 'Euler Angles');
hold on;
plot(DeployData(:,1), euler(:,1).*180/pi, 'rx');
plot(DeployData(:,1), euler(:,2).*180/pi, 'gx');
plot(DeployData(:,1), euler(:,3).*180/pi, 'bx');
datetick('x',6,'keepticks','keeplimits')

title('Euler angles');
xlabel('Time (mm/dd)');
ylabel('Angle (deg)');

% phi is a rotation around X, theta around Y and psi around Z
legend('phi', 'theta', 'psi');

figureName=strcat('Euler_OverDeployment');
saveas(gcf,strcat(figureName,'.tiff'));

% c=find(DeployData(:,9)==0);
% DeployData(c,9)=NaN;


figure('Name', 'Depth');
hold on;
plot(DeployData(:,1),((((DeployData(:,9))*2-0.5)*70/4)-1)*10,'rx');
datetick('x',6,'keepticks','keeplimits')

title('Depth Data over Duration of Deployment');
xlabel('Time (mm/dd)');
ylabel('Decibar');
saveas(gcf,strcat('Depth over Deployment','.tiff'));


figure('Name', 'Accelerations');
plot(DeployData(:,1),DeployData(:,2),'r',DeployData(:,1),DeployData(:,3),'g',DeployData(:,1),DeployData(:,4),'b');
legend('x','y','z');
xlabel('Time (mm:ss)');
ylabel('Acceleration (g)');
title([fileName ' Accelerations (g)  ' datestr(AllData(1,1))]);
datetick('x','mm/dd','keepticks','keeplimits')

figureName='Accelerations over Deployment';
saveas(gcf,strcat(figureName,'.tiff'));

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%WATCH CYCLE

for i= 2:5,
    if i<10
    fileName=strcat('BED0000',int2str(i),'.WAT.OUT');
    processBEDData(fileName);
    elseif i<100&& i>=10
    fileName=strcat('BED000',int2str(i),'.WAT.OUT');
    processBEDData(fileName);
    
    else
    fileName=strcat('BED00',int2str(i),'.WAT.OUT');
    processBEDData(fileName);
    end
end

close all;
clear all;
DeployData=[];

for i=2:5,
    if i<10
     fileName=strcat('BED0000',int2str(i),'_WAT.mat');
   load(fileName);
  DeployData=[DeployData;AllData];
     elseif i<100&& i>=10
  
        fileName=strcat('BED000',int2str(i),'_WAT.mat');
   load(fileName);
  DeployData=[DeployData;AllData];
    elseif i > 100
   fileName=strcat('BED00',int2str(i),'_WAT.mat');
   load(fileName);
  DeployData=[DeployData;AllData];
    else
       
    end
  
end

euler=[];
 euler=quatern2euler(quaternConj(DeployData(:,5:8))); % use conjugate for sensor frame relative to Earth

figure('Name', 'Euler Angles');
hold on;
plot(DeployData(:,1), euler(:,1).*180/pi, 'rx');
plot(DeployData(:,1), euler(:,2).*180/pi, 'gx');
plot(DeployData(:,1), euler(:,3).*180/pi, 'bx');
datetick('x',16,'keepticks','keeplimits')

title('Euler angles');
xlabel('Time (mm/dd)');
ylabel('Angle (deg)');

% phi is a rotation around X, theta around Y and psi around Z
legend('phi', 'theta', 'psi');
STR = input('Enter the filename for this figure (no extension):','s');
saveas(gcf,strcat(STR,'.tiff'));


for i=38:40,
    
   fileName=strcat('BED000',int2str(i),'.mat');
   load(fileName);
  DeployData=[DeployData;AllData];
   
end

figure('Name', 'Euler Angles');
hold on;
plot(DeployData(:,1), euler(:,1).*180/pi, 'rx');
plot(DeployData(:,1), euler(:,2).*180/pi, 'gx');
plot(DeployData(:,1), euler(:,3).*180/pi, 'bx');
datetick('x',16,'keepticks','keeplimits')

title('Euler angles');
xlabel('Time (mm/dd)');
ylabel('Angle (deg)');

% phi is a rotation around X, theta around Y and psi around Z
legend('phi', 'theta', 'psi');

