Save animation from PDE modeler
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
How to save animation from PDE modeler??
0 commentaires
Réponses (1)
Ayush
le 27 Mai 2024
Modifié(e) : Ayush
le 27 Mai 2024
Hi,
As a work around to save animation from the PDE modeler, you can capture frames during the simulation and then write them into a video file. For this, you can use the "VideoWriter", "getframe" and "writeVideo" functions. Refer to the pseudo-code below:
% Assuming you have a PDE model 'model' and its solution 'result'
% Create a figure
fig = figure;
% Define the video writer
v = VideoWriter('pde_animation.avi');
open(v);
% Assume 'tlist' is the list of time points for the solution
for t = tlist
% Select the solution at time t
u = result.NodalSolution(:, t);
% Plot the solution
pdeplot(model, 'XYData', u);
% Capture the plot as a frame
frame = getframe(fig);
% Write the frame to the video
writeVideo(v, frame);
end
% Close the video file
close(v);
In the above example, it can be seen that to create a video, I'm using the "VideoWriter" function, which defines the format of the video to be saved. The result plots at every time instance are used as frames for my video, for which the "getframe" and "writeVideo" functions help me.
For more information on the "VideoWriter" and "getframe" functions, refer to the below documentations:
0 commentaires
Voir également
Catégories
En savoir plus sur Audio and Video Data dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!