MATLAB: Unwanted line on plot

graphplot

I am plotting real time data and I have a continually updating plot. I want to show 50 points on the graph and update as more data comes in. Here is currently what I am doing:
while 1
for i=1:50
plot(x,y)
end
end
Now the problem with this is that once the for loop gets back to the first element, on the plot there is a line that connects the left most data point to the right most data point and continues until the program is stopped.
Is there anyway to get around this line?
EDIT: Adding the complete example
count = 0;
while count < 3
for i = 1 : 30
num1 = rand + 1;
Out1(i) = num1;
c=clock;
Time(i)=(c(5)+(c(6)/100));
plot(Time,Out1)
drawnow();
end
count = count + 1;
end

Best Answer

Is this what you're looking for?
count = 0;
Out1 = nan(1, 30);
Time = nan(1, 30);
while count < 3
for i = 1 : 30
num1 = rand + 1;
c=clock;
Out1 = [Out1(2:end), num1];
Time = [Time(2:end), (c(5)+(c(6)/60))];
plot(Time,Out1)
pause(0.1);
end
count = count + 1;
end