function [Td_inpn, Td_inph, Td_inpu] = tinput(Td)

%% NORMAL, horizontal, friction tapete
%%Extract steps 
for HH=1:3:27
    
   Mn=(min(Td(:,HH)))+250;
a=1; x=-1; j=1; z=0; b=0; indzero=(find(Td(a:end,HH)<Mn & Td(a:end,HH)>200))'; a1=indzero(1);
for g=1:1:11
    while x==-1
        x=indzero(1,j)-indzero(1,j+1); j=j+1; z=z+1; %n de zeros (pontos - pé no ar)
    end
    y=indzero(1,j-1)-indzero(1,j); a=a1+b+z; c=a-y-1;
    if g ~=1 %step index
        I(HH,g)=a+1; %start step
        F(HH,g)=c; %end step
    end
    b=c; z=0; x=-1; a1=0;
end
end

%%Remove zeros
for HH=1:3:27
bb=1;
for hhh=1:1:size(I,2)
    if F(HH,hhh)-I(HH,hhh) > 70 
        II(HH,bb) = I(HH,hhh); FF(HH,bb) = F(HH,hhh); bb=bb+1;    
    end
end
end

%%check 'steps' lenght left
for HH=1:3:27
jg=size(FF,2);
for kh=1:1:jg;
gj(HH,kh)=FF(HH,kh)-II(HH,kh);
end
end

%normalll
yy=1;
for HH=1:3:27
for xx=1:1:size(II,2);
    if((FF(HH,xx)-II(HH,xx))>0)
    Td_inpn{yy}=Td(II(HH,xx):FF(HH,xx),HH);
    yy=yy+1;
    end
end
end
%horizontal

yy=1;
for HH=1:3:27
for xx=1:1:size(II,2);
    if((FF(HH,xx)-II(HH,xx))>0)
    Td_inph{yy}=Td(II(HH,xx):FF(HH,xx),HH+1);
    yy=yy+1;
    end
end
end
%friction

yy=1;
for HH=1:3:27
for xx=1:1:size(II,2);
    if((FF(HH,xx)-II(HH,xx))>0)
    Td_inpu{yy}=Td(II(HH,xx):FF(HH,xx),HH+2);
    yy=yy+1;
    end
end
end

%pad

% AUX=max(cellfun('size',Td_inpn,1)); %- min(cellfun('size',Cd_inpu,1));
% 
% for HH=1:1:size(Td_inpn,2)
%     Td_inpn{HH}=padarray(Td_inpn{HH},(AUX-size(Td_inpn{HH},1))+3.,0,'post');
%     Td_inph{HH}=padarray(Td_inph{HH},(AUX-size(Td_inph{HH},1))+3,0,'post');
%     Td_inpu{HH}=padarray(Td_inpu{HH},(AUX-size(Td_inpu{HH},1))+3,0,'post');
% end