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
2010-2-24
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Interactive Control and Callbacks 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!