how do i close plotted graph?

3 views (last 30 days)
Kritank Kalyan
Kritank Kalyan on 18 Dec 2018
Commented: Star Strider on 18 Dec 2018
I am trying to close a graph automatically after 5 second of view

Accepted Answer

Star Strider
Star Strider on 18 Dec 2018
Try this:
figure
plot(randn(1, 10))
hf = gcf;
pause(5)
close(hf)
  4 Comments
Guillaume
Guillaume on 18 Dec 2018
As long as pause is on!
Possibly safer:
hf = figure;
plot(randn(1, 10));
t = timer('StartDelay', 5, 'TimerFcn', @(~, ~) close(hf));
start(t);

Sign in to comment.

More Answers (0)

Categories

Find more on Mathematics 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!