clc

ini=x(1,1);

%%%%%%%%%%%%%%
%   IM_ACQ   %
%%%%%%%%%%%%%%
xx=x-ini;
fimx=xx(end,end);
x1=(xx(:,2)-xx(:,1))/1000;
% plot(x1)
mediax=mean(x1)
desviox=std(x1)
minx=min(x1)
maxx=max(x1)

figure
subplot(4,1,4)
stem(xx(:,1),ones(1,length(xx)));
hold on
stem(xx(:,2),ones(1,length(xx)),'rx')
hold off

%%%%%%%%%%%%%%%
%   IM_PROC   %
%%%%%%%%%%%%%%%
yy=y-ini;
fimy=yy(end,end);
y1=(yy(:,2)-yy(:,1))/1000;
% plot(y1)
mediay=mean(y1)
desvioy=std(y1)
miny=min(y1)
maxy=max(y1)

subplot(4,1,3)
stem(yy(:,1),ones(1,length(yy)),'g');
hold on
stem(yy(:,2),ones(1,length(yy)),'rx')
hold off

%%%%%%%%%%%%%%%%%
%   OBJ_TRACK   %
%%%%%%%%%%%%%%%%%
zz=z-ini;
fim=zz(end,end);
z1=(zz(:,2)-zz(:,1))/1000;
% plot(z1)
mediaz=mean(z1)
desvioz=std(z1)
minz=min(z1)
maxz=max(z1)

subplot(4,1,2)
stem(zz(:,1),ones(1,length(zz)),'k');
hold on
stem(zz(:,2),ones(1,length(zz)),'rx')
hold off

%%%%%%%%%%%%
%   CTRL   %
%%%%%%%%%%%%
ww=w-ini;
fim=ww(end,end);
w1=(ww(:,2)-ww(:,1))/1000;
% plot(w1)
mediaw=mean(w1)
desviow=std(w1)
minw=min(w1)
maxw=max(w1)

subplot(4,1,1)
stem(ww(:,1),ones(1,length(ww)));
hold on
stem(ww(:,2),ones(1,length(ww)),'rx')
hold off

%%%%%%%%%%%%%%%%%%%
%   GLOBAL_VIEW   %
%%%%%%%%%%%%%%%%%%%

figure
hold on
stem(xx(:,1),ones(1,length(xx)),'r');
stem(yy(:,1),ones(1,length(yy)),'g');
stem(zz(:,1),ones(1,length(zz)),'y');
stem(ww(:,1),ones(1,length(ww)),'b');
hold off

figure
hold on
stem(xx(:,2),ones(1,length(xx)),':rx')
stem(yy(:,2),ones(1,length(yy)),':gx')
stem(zz(:,2),ones(1,length(zz)),':yx')
stem(ww(:,2),ones(1,length(ww)),':bx')
hold off
% xp=[];
% j=1;
% % i=1:1:fim;
% for i=1:1:100000
%     if i >= x(j,1)
%         if i <= x(j,2)
%             xp(i)= 1;
%         else
%             xp(i)=0;
%             if(j == length(j))
%                 break;
%             end
%             j=j+1;
%         end
%     else
%         xp(i)=0;
%     end
% end
