%% Data from ultrasound sensors

close all; clear all; clc;


%% 3_Passagem_10cm

[time,s1,s2,s3] = textread('3_Passagem_10cm','%d %f %f %f','headerlines',1);

s1(s1==0)=NaN;
s2(s2==0)=NaN;
s3(s3==0)=NaN;
time=linspace(1, length(s1), length(s1));
windowSize = 10;

tmax=max(time);
% s1=filter(ones(1,windowSize)/windowSize,1,s1);
% s2=filter(ones(1,windowSize)/windowSize,1,s2);
% s3=filter(ones(1,windowSize)/windowSize,1,s3);

x_min=0;
x_max=tmax;
y_min=0;
y_max=600;

subplot(1,3,1); plot(time, s1, 'b');
xlabel('time');
ylabel('distance (cm)');
legend('Sensor1')
axis([x_min x_max y_min y_max]);
subplot(1,3,2); plot(time, s2, 'r');
TITLE('3_Passagem_10cm');
xlabel('time');
ylabel('distance (cm)');
legend('Sensor2')
axis([x_min x_max y_min y_max]);
subplot(1,3,3); plot(time, s3, 'g');
xlabel('time');
ylabel('distance (cm)');
legend('Sensor3')
axis([x_min x_max y_min y_max]);

min(s1)
min(s2)
min(s3)

%% 3_Passagem_5cm
close all; clear all; clc;

[time,s1,s2,s3] = textread('3_Passagem_5cm','%d %f %f %f','headerlines',1);

s1(s1==0)=NaN;
s2(s2==0)=NaN;
s3(s3==0)=NaN;
time=linspace(1, length(s1), length(s1));
windowSize = 10;

tmax=max(time);
% s1=filter(ones(1,windowSize)/windowSize,1,s1);
% s2=filter(ones(1,windowSize)/windowSize,1,s2);
% s3=filter(ones(1,windowSize)/windowSize,1,s3);

x_min=0;
x_max=tmax;
y_min=0;
y_max=650;

subplot(1,3,1); plot(time, s1, 'b');
xlabel('time');
ylabel('distance (cm)');
legend('Sensor1')
axis([x_min x_max y_min y_max]);
subplot(1,3,2); plot(time, s2, 'r');
TITLE('3_Passagem_5cm');
xlabel('time');
ylabel('distance (cm)');
legend('Sensor2')
axis([x_min x_max y_min y_max]);
subplot(1,3,3); plot(time, s3, 'g');
xlabel('time');
ylabel('distance (cm)');
legend('Sensor3')
axis([x_min x_max y_min y_max]);
min(s1)
min(s2)
min(s3)

%% 3_Passagem_2cm
close all; clear all; clc;

[time,s1,s2,s3] = textread('3_Passagem_2cm','%d %f %f %f','headerlines',1);

s1(s1==0)=NaN;
s2(s2==0)=NaN;
s3(s3==0)=NaN;
time=linspace(1, length(s1), length(s1));
windowSize = 10;

tmax=max(time);
% s1=filter(ones(1,windowSize)/windowSize,1,s1);
% s2=filter(ones(1,windowSize)/windowSize,1,s2);
% s3=filter(ones(1,windowSize)/windowSize,1,s3);

x_min=0;
x_max=tmax;
y_min=0;
y_max=600;

subplot(1,3,1); plot(time, s1, 'b');
xlabel('time');
ylabel('distance (cm)');
legend('Sensor1')
axis([x_min x_max y_min y_max]);
subplot(1,3,2); plot(time, s2, 'r');
TITLE('3_Passagem_2cm');
xlabel('time');
ylabel('distance (cm)');
legend('Sensor2')
axis([x_min x_max y_min y_max]);
subplot(1,3,3); plot(time, s3, 'g');
xlabel('time');
ylabel('distance (cm)');
legend('Sensor3')
axis([x_min x_max y_min y_max]);

min(s1)
min(s2)
min(s3)


%% 3_Cantos_10cm
close all; clear all; clc;

[time,s1,s2,s3] = textread('3_Cantos_5cm','%d %f %f %f','headerlines',1);

s1(s1==0)=NaN;
s2(s2==0)=NaN;
s3(s3==0)=NaN;
time=linspace(1, length(s1), length(s1));
windowSize = 10;

tmax=max(time);
% s1=filter(ones(1,windowSize)/windowSize,1,s1);
% s2=filter(ones(1,windowSize)/windowSize,1,s2);
% s3=filter(ones(1,windowSize)/windowSize,1,s3);

x_min=0;
x_max=tmax;
y_min=0;
y_max=600;

subplot(1,3,1); plot(time, s1, 'b');
xlabel('time');
ylabel('distance (cm)');
legend('Sensor1')
axis([x_min x_max y_min y_max]);
subplot(1,3,2); plot(time, s2, 'r');
TITLE('3_Cantos_5cm');
xlabel('time');
ylabel('distance (cm)');
legend('Sensor2')
axis([x_min x_max y_min y_max]);
subplot(1,3,3); plot(time, s3, 'g');
xlabel('time');
ylabel('distance (cm)');
legend('Sensor3')
axis([x_min x_max y_min y_max]);

min(s1)
min(s2)
min(s3)

%% 3_Cantos_10cm
close all; clear all; clc;

[time,s1,s2,s3] = textread('3_Cantos_10cm','%d %f %f %f','headerlines',1);

s1(s1==0)=NaN;
s2(s2==0)=NaN;
s3(s3==0)=NaN;
time=linspace(1, length(s1), length(s1));
windowSize = 10;

tmax=max(time);
% s1=filter(ones(1,windowSize)/windowSize,1,s1);
% s2=filter(ones(1,windowSize)/windowSize,1,s2);
% s3=filter(ones(1,windowSize)/windowSize,1,s3);

x_min=0;
x_max=tmax;
y_min=0;
y_max=600;

subplot(1,3,1); plot(time, s1, 'b');
xlabel('time');
ylabel('distance (cm)');
legend('Sensor1')
axis([x_min x_max y_min y_max]);
subplot(1,3,2); plot(time, s2, 'r');
TITLE('3_Cantos_10cm');
xlabel('time');
ylabel('distance (cm)');
legend('Sensor2')
axis([x_min x_max y_min y_max]);
subplot(1,3,3); plot(time, s3, 'g');
xlabel('time');
ylabel('distance (cm)');
legend('Sensor3')
axis([x_min x_max y_min y_max]);

min(s1)
min(s2)
min(s3)
%%