how do i close plotted graph?

I am trying to close a graph automatically after 5 second of view

 Accepted Answer

Try this:
figure
plot(randn(1, 10))
hf = gcf;
pause(5)
close(hf)

4 Comments

+1 nice and easy
Thank you!
As long as pause is on!
Possibly safer:
hf = figure;
plot(randn(1, 10));
t = timer('StartDelay', 5, 'TimerFcn', @(~, ~) close(hf));
start(t);
Good point!

Sign in to comment.

More Answers (0)

Categories

Find more on 2-D and 3-D Plots 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!