JohnnyF
JohnnyF

Reputation: 1101

MATLAB- adding a line to plot (scatter)

I am making a "movie" where the dots should move each X time

Here is the code (not copy paste so dont fix typos)

loop:
scatter(x,y,[],colors)
axies (a b c d)
pause(0.01);
end loop;

This is working great, but how can i add a LINE for the X axise (1:140)

At height 150?

I tired hold on but it just make a mess... or what is the command to clean grough when its in hold on?

Upvotes: 0

Views: 627

Answers (1)

Jørgen
Jørgen

Reputation: 863

Could this work for you?

N = 1000;
X = 1:N;
M = 160;
Y = randi(M, N);

figure
for i = 1:N
    x = X(i);
    y = Y(i);
    scatter(x,y,[])
    hold on
    line([1 N], [150 150])
    hold off
    axis([1 N 0 200])
    pause(0.01);
end

Upvotes: 3

Related Questions