How to animated multiple plots?

66 views Asked by At

I try to created some sort plot lines moving from left to right then that I wanted to ask is after the line that moves from left to right then a few moments later there was another line that follows the line so as it would if the first line of the line then there is a second line that trailed I 've tried to make but that I could just like this The first car has reached the end of the next new line coming when the first line of the road may reach a point 100 , and then the second line in the rear had come following the first line at the same speed

Here's the code I use:

function lalu_lintas

X=0:1.0:1000;

NX=length(X);

function y=f(X)

    for j=1:NX

        if X(j)==0
           y(j)=1.0;
        else
            y(j)=0;
        end
    end
end

c = 1;

T=0:1.0:1000;

NT=length(T);

for i=1:NT

    i

    rho=f(X-c*T(i));

    plot(X,rho)

    pause(0.0001)   

end


end
1

There are 1 answers

0
lhcgeneva On

What about using

if i > 100
    hold on; plot(X-100, rho);
    hold off
end

underneath your plot(X,rho)?