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

44 次查看(过去 30 天)
I have subplots in my figure and want to use the MOVIE command to make an animation playing those subplots at the same time.

采纳的回答

MathWorks Support Team
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

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Interactive Control and Callbacks 的更多信息

标签

尚未输入任何标签。

产品

Community Treasure Hunt

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

Start Hunting!

Translated by