save animation in subplot

13 visualizaciones (últimos 30 días)
feynman feynman
feynman feynman el 15 de Ag. de 2024
Comentada: Walter Roberson el 18 de Nov. de 2024 a las 6:11
I'm using
while
drawnow;hold off
end
to create an animation. But this animation is just the 6th position as in subplot(2,3,6) (or through next tile repeatedly). To save this animation to the computer while not keeping the other subplots 1~5, what to do?
  2 comentarios
Walter Roberson
Walter Roberson el 16 de Ag. de 2024
??
That is an infinite loop. Inside the infinite loop, you request that the graphics queue be flushed, and you turn off hold . But you do not do anything else -- no drawing at all, no recording of previously drawn material.
It is not clear what you are trying to do?
feynman feynman
feynman feynman el 14 de Nov. de 2024 a las 5:03
thanks for your answer. I omitted '%draw something' as in your code

Iniciar sesión para comentar.

Respuesta aceptada

Walter Roberson
Walter Roberson el 16 de Ag. de 2024
ax6 = subplot(2,3,6);
count = 0;
while true
%draw something
count = count + 1;
filename = fullfile(SAVEDIRECTORY, "image" + count + ".png");
exportgraphics(ax6, filename);
end
  4 comentarios
feynman feynman
feynman feynman el 18 de Nov. de 2024 a las 6:03
Editada: feynman feynman el 18 de Nov. de 2024 a las 6:04
good to hear that. Then how does ax6 = subplot(2,3,6) get in without exportgraphics()?
Walter Roberson
Walter Roberson el 18 de Nov. de 2024 a las 6:11
You have getframe(gcf) which captures the image of the entire current figure.
Note that you could also getframe(ax6) if you wanted to capture subplot(2,3,6) only.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Animation en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by