Animate results from PDE toolbox

16 次查看(过去 30 天)
Hi,
I am trying to animate results from a PDE toolbox script.
F=figure(1);
MyVideo = VideoWriter(sprintf('2DSys.avi'));
MyVideo.FrameRate = 10;
MyVideo.Quality = 100;
open(MyVideo);
for i = 1:length(result.SolutionTimes)
pdeplot(MyModel,'XYData',result.NodalSolution(:,i),'ColorBar','off');
title({['Time=' num2str(result.SolutionTimes(i)) 's']})
% colormap(jet)
% axis tight
% ax = gca;
% axis off
M(:,i) = getframe(F);
writeVideo(MyVideo, M(:,i));
drawnow
end
But I don't have any frames written to my file. The script is executing without errors on my pc.
On analyzing my M output structure I see that the colormap entries turn out empty. Attaching M as well.

采纳的回答

VBBV
VBBV 2022-11-22
M(:,i) = getframe(gcf); % use gcf
  7 个评论
Hashim
Hashim 2022-11-22
编辑:Hashim 2022-11-22
The script that I attached is not running. I have already attached the result variable that has the values I want to animate. The rest of the script seems to be working fine.
Hashim
Hashim 2022-12-6
编辑:Hashim 2022-12-6
This kinda works
figure;
maxc = max(max(result.NodalSolution));
minc = min(min(result.NodalSolution));
MyVideo = VideoWriter(sprintf('2DSys.avi'));
MyVideo.FrameRate = 10;
MyVideo.Quality = 100;
open(MyVideo);
for i = 1:10
pdeplot(MyModel,'XYData',result.NodalSolution,'ColorBar','off','Mesh','off');
title({['Time=' num2str(i) 's']})
caxis([minc maxc]);
colormap(jet)
axis tight
ax = gca;
ax.DataAspectRatio = [1 1 1];
M(i) = getframe(gcf);
writeVideo(MyVideo, M);
end
close(MyVideo)

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Geometry and Mesh 的更多信息

产品


版本

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by