%% cálculo da magnitude da aceleração
clear all, close all, clc

save_id = 0;


move_zz
accel_sensivity = (1/256)*9.81; %COnverte ADC em m/s^2
accel_length = sqrt(sensors_data(:,1,1).^2+sensors_data(:,2,1).^2+sensors_data(:,3,1).^2)*accel_sensivity;
static_threshold_max = (256+15)*accel_sensivity;
static_threshold_min = (256-15)*accel_sensivity;
figure
hold on, grid on
plot(sensors_time(:,1),accel_length,'b','LineWidth',3)
plot(sensors_time(:,1),ones(1,size(sensors_data,1))*static_threshold_max,'r','LineWidth',2)
plot(sensors_time(:,1),ones(1,size(sensors_data,1))*static_threshold_min,'r','LineWidth',2)
xlabel('Tempo [seg]','FontSize',14)
ylabel('Magnitude aceleração [m/s^2]','FontSize',14)
legend('magnitude','limiar')
set(gca,'FontSize',14)
if save_id == 1
    saveas(gca,'/home/telmo/Dropbox/Dissertacao/tese_escrita2/Imagens/final_experiments/accel_length_zz','jpg')
end

clear all
save_id = 0;

move_xx
accel_sensivity = (1/256)*9.81; %COnverte ADC em m/s^2
accel_length = sqrt(sensors_data(:,1,1).^2+sensors_data(:,2,1).^2+sensors_data(:,3,1).^2)*accel_sensivity;
static_threshold_max = (256+15)*accel_sensivity;
static_threshold_min = (256-15)*accel_sensivity;

figure
hold on, grid on
plot(sensors_time(:,1),accel_length,'b','LineWidth',3)
plot(sensors_time(:,1),ones(1,size(sensors_data,1))*static_threshold_max,'r','LineWidth',2)
plot(sensors_time(:,1),ones(1,size(sensors_data,1))*static_threshold_min,'r','LineWidth',2)
xlabel('Tempo [seg]','FontSize',14)
ylabel('Magnitude aceleração [m/s^2]','FontSize',14)
legend('magnitude','limiar')
set(gca,'FontSize',14)
if save_id == 1
    saveas(gca,'/home/telmo/Dropbox/Dissertacao/tese_escrita2/Imagens/final_experiments/accel_length_xx','jpg')
end


clear all
save_id = 0;

move_yy
accel_sensivity = (1/256)*9.81; %COnverte ADC em m/s^2
accel_length = sqrt(sensors_data(:,1,1).^2+sensors_data(:,2,1).^2+sensors_data(:,3,1).^2)*accel_sensivity;
static_threshold_max = (256+15)*accel_sensivity;
static_threshold_min = (256-15)*accel_sensivity;
figure
hold on, grid on
plot(sensors_time(:,1),accel_length,'b','LineWidth',3)
plot(sensors_time(:,1),ones(1,size(sensors_data,1))*static_threshold_max,'r','LineWidth',2)
plot(sensors_time(:,1),ones(1,size(sensors_data,1))*static_threshold_min,'r','LineWidth',2)
xlabel('Tempo [seg]','FontSize',14)
ylabel('Magnitude aceleração [m/s^2]','FontSize',14)
legend('magnitude','limiar')
set(gca,'FontSize',14)
if save_id == 1
    saveas(gca,'/home/telmo/Dropbox/Dissertacao/tese_escrita2/Imagens/final_experiments/accel_length_yy','jpg')
end
