How can i prevent the plots from appearing while still using them as frames for the movie function?

3 views (last 30 days)
I have a script written out that in a loop plots out multiple curves. I then use getframe to put the frames in a vector. After the loop I use the movie function to play the frames. Thus, the frames are played out twice: once when being plotted and once with the movie function. My question is: Is there a way to suppress the plotted figures so that it is only played with the movie function. I want to suppress the first one so that i can have better control over the framerate as given by the movie funnction

Answers (1)

Tommy
Tommy on 12 May 2020
Plot your frames on a figure whose Visible property is set to 'off':
fig = figure('Visible', 'off');
ax = axes(fig);
x = linspace(0,2*pi,1000);
N = 25; fps = 15;
frames(N) = struct('cdata',[],'colormap',[]);
for i = 1:N
plot(ax, x, sin(x+i)); axis tight;
frames(i) = getframe(fig);
end
clf(fig);
fig.Visible = 'on';
movie(fig, frames, 1, fps);

Categories

Find more on 2-D and 3-D Plots in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!