clear;

freq = 50.0; %Hz
t_step = 1/freq; %s

flat = loadData('flat_5min_50Hz');
ang1 = loadData('angle1_5min_50hz');
ang2 = loadData('angle2_5min_50hz');
ang3 = loadData('angle3_5min_50hz');
ang4 = loadData('angle4_5min_50hz');
ang5 = loadData('angle5_5min_50hz');

% Find the shortest dataset, trim all the others to the same length, plot
[minLength, dataset] = min([length(flat.accel) length(ang1.accel) length(ang2.accel)...
    length(ang3.accel) length(ang4.accel) length(ang5.accel)]);

a_z(1,:) = flat.accel(1:minLength, 3);
a_z(2,:) = ang1.accel(1:minLength, 3);
a_z(3,:) = ang2.accel(1:minLength, 3);
a_z(4,:) = ang3.accel(1:minLength, 3);
a_z(5,:) = ang4.accel(1:minLength, 3);
a_z(2,:) = ang5.accel(1:minLength, 3);

t_secs = 0:t_step:(length(a_z(1,:))-1)/freq;

plot(a_z(1,:))

% flat_Az = flat.accel(:,3);
% propped_Az = propped.accel(:,3);
% 
% t_secs_flat = 0:.01:(length(flat.accel)-1)/100.0;
% t_secs_propped = 0:.01:(length(propped.accel)-1)/100.0;
% 
% figure;
% subplot(2,1,1);
% plot(t_secs_flat, flat_Az);
% xlabel('Time (s)');
% ylabel('Z acceleration (m/s^2)');
% title('Flat IMU');
% ylim([-9.8 -9.4]);
% subplot(2,1,2);
% plot(t_secs_propped, propped_Az);
% xlabel('Time (s)');
% ylabel('Z acceleration (m/s^2)');
% title('Propped IMU');
% ylim([-9.8 -9.4]);
% 
% mean(flat_Az)
% mean(propped_Az)
