How do I capture a movie with all the subplots in a figure in MATLAB?

47 views (last 30 days)
I have subplots in my figure and want to use the MOVIE command to make an animation playing those subplots at the same time.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 24 Feb 2010
You can specify the figure handle as an input to GETFRAME to capture the entire figure including subplots in a single frame of the movie. You can then play back this movie as you would a movie with a single axes.
For example,
fig = figure('position',[100 100 850 600]);
x = 1:10;
for i = 1:10
subplot(2,1,1);
plot(x);
x = fliplr(x);
subplot(2,1,2);
plot(rand(1,10));
f(i) = getframe(fig);
end
close all
[h, w, p] = size(f(1).cdata); % use 1st frame to get dimensions
hf = figure;
% resize figure based on frame's w x h, and place at (150, 150)
set(hf, 'position', [150 150 w h]);
axis off
movie(hf,f);
mplay(f)
For more information on GETFRAME, consult the reference page by executing
doc getframe

More Answers (0)

Categories

Find more on Interactive Control and Callbacks in Help Center and File Exchange

Tags

No tags entered yet.

Products

Community Treasure Hunt

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

Start Hunting!