Dynamic graph of polygonial lines

Hi, I am trying to solve this issue for couple of weeks. I want to have a single 2d figure on which I will draw not-closed 3 polygonial lines of different colors.
So pseudocode should be something like this:
draw(path1,path2,path3);
for i=1:10
path1=f1();
path2=f2();
path3=f3();
draw(path1, path2, path3);
User should just watch it, without need to click anything.
Can you give me some hint, please.
Thank you

 Accepted Answer

doc pause
doc drawnow
Example:
hold all
h1 = plot(rand(100,1));
h2 = plot(rand(100,1));
h3 = plot(rand(100,1));
drawnow
hold off
for k=1:10
set(h1,'ydata',rand(100,1))
set(h2,'ydata',rand(100,1))
set(h3,'ydata',rand(100,1))
pause(0.5)
end

2 Comments

Thank you very much!
Is it possible to same-color lines be not-connected? Like in this picture: http://i51.tinypic.com/2wns3v8.png
Color of each line you can set as follows:
h = plot(rand(100,1),'Color',[1 0 0]);
for k=1:10
set(h,'Color',[k/10 1-k/10 0.5+k/20])
pause(0.5)
end

Sign in to comment.

More Answers (0)

Categories

Find more on Creating, Deleting, and Querying Graphics Objects in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!