function y = ttzapis(u)

global plot_on
global data_history

if((plot_on==0) && (u(1)==1))
    data_history=[];
end;


if(u(1)==1)
    data_history =  [data_history, u(2:length(u))];
end;

if((plot_on==1) && (u(1)==0))
%     plot(data_history(1,:),data_history(2,:));
%     hold on;
%     colors = {'r','g','k','m'};
%     for ttxx = 3:min(size(data_history));
%         ttxx;
%         plot(data_history(1,:),data_history(ttxx,:),colors{ttxx-2}); %
%     end;
    subplot(4,1,1);
    hold on;
    plot(data_history(1,:),data_history(2,:),'b');
    plot(data_history(1,:),data_history(3,:),'c');
    plot(data_history(1,:),data_history(4,:),'k');
    legend('h_1_/_2','u_1','e_1','Location','EastOutside');
    hold off;

    subplot(4,1,2);
    hold on;
    plot(data_history(1,:),data_history(5,:),'r');
    plot(data_history(1,:),data_history(6,:),'c');
    plot(data_history(1,:),data_history(7,:),'k');
    legend('h_3','u_3','e_3','Location','EastOutside');
    hold off;
    
    subplot(4,1,3);
    hold on;
    plot(data_history(1,:),data_history(8,:),'g');
    plot(data_history(1,:),data_history(9,:),'b');
    plot(data_history(1,:),data_history(10,:),'r');
    legend('h_1','h_2','h_3','Location','EastOutside');
    hold off; 
    
    subplot(4,1,4);
    hold on;
    plot(data_history(1,:),data_history(11,:),'m--');
    plot(data_history(1,:),data_history(12,:),'m-.');
    legend('u_1','u_3','Location','EastOutside');
    hold off;    
end;







plot_on = u(1);

%y = plot_on;
y = length(data_history);
