MATLAB: How do i close plotted graph close funtion I am trying to close a graph automatically after 5 second of view Best Answer Try this: figureplot(randn(1, 10))hf = gcf;pause(5)close(hf) Related SolutionsMATLAB: How to clear only a part of the plot figurehold onh1 = plot(rand(10,1)) ;h2 = plot(rand(10,1)) ;h3 = plot(rand(10,1)) ;h4 = plot(rand(10,1)) ;set(h2,'Visible','off')set(h4,'Visible','off') MATLAB: Varying timer’s period inside the TimerFcn This page mentions an approach to vary the period of timer: https://stackoverflow.com/questions/15576682/matlab-change-repeating-timer-period Here I show the method mentioned in the second answer. This example sets a random time period between 1 to 5 seconds after each callback of timer.t = timer('StartDelay', 1, 'TimerFcn', @timerFcn, ... 'StopFcn', @timerStopFcn, 'ExecutionMode', 'singleShot');start(t);function timerFcn(obj, ~) disp(obj.StartDelay)endfunction timerStopFcn(obj, ~) period = randi([1 5]); obj.StartDelay = period; start(obj);end Related QuestionPlots do not immediately follow commands in the live editor with output inline.How to pause the execution of one timer while continuing to execute another timer in MATLAB 7.8 (R2009a)Dynamic graph of polygonial linesExecute command if timer runs out
Best Answer