Plotting in Multiple Figures inside Loop
105 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Kyle
am 14 Jul. 2011
Kommentiert: Monowar Hossain
am 17 Aug. 2022
I'm trying to plot data on two different figures within a loop. When I do this, the computer flashes between the two figures in each iteration, which slows down the program considerably. Is there a way to hide the figures until the loop is finished?
for i = 1:100
...
figure(1)
plot(data1, data2)
figure(2)
plot(data1, data3)
end
1 Kommentar
Akzeptierte Antwort
Patrick Kalita
am 14 Jul. 2011
Calling the figure command will cause the graphics queue to flush (basically like a drawnow call). That's what is slowing the program down. Instead of calling figure, you can get the same effect -- without the implicit drawnow -- by setting the root's CurrentFigure property:
f1 = figure;
f2 = figure;
for i = 1:100
...
set(0, 'CurrentFigure', f1)
plot(data1, data2)
set(0, 'CurrentFigure', f2)
plot(data1, data3)
end
0 Kommentare
Weitere Antworten (1)
Sean de Wolski
am 14 Jul. 2011
Yes; build you data1-3 vectors inside the loop and then plot once after it.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Graphics Performance finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!