MATLAB: Creat a highway with driving cars’+’ and a police’>`on it.

random walkstreet line

The cars should drive with a rand speed on three lines i don't know how to make them move.

Best Answer

Use a loop. Inside the loop, call plot(), drawnow, and pause:
for k = 1 : numIterations
% Determine coordinates for cars and police. You do this, not me.
% Now plot them all.
cla;
plot(xCars, yCars, 'b+', 'MarkerSize', 20, 'LineWidth', 2);
hold on;
plot(xPolice, yPolice, 'r>', 'MarkerSize', 20, 'LineWidth', 2);
drawnow;
pause(0.3); % Pause long enough to see this iteration.
end
Related Question