How to create a gif?

5 visualizaciones (últimos 30 días)
Niloufar
Niloufar el 27 de Dic. de 2022
Respondida: Simon Chan el 27 de Dic. de 2022
I have a code to generate a wave equation gif.but it just includes the last frame and I don't know what the problem is.here is my code:
clear;clc;close all;
%figure('Name','wave equation');
a = 1;
t0 = 1;
syms x;
f = @(x) ((a/t0)*x + a).*(x>-t0 & x<0) + ((-a/t0)*x + a).*(x>=0 & x<t0);
for c = 0:0.05:2
my_plot = fplot((f(x-c) + f(x+c))/2,[-t0 t0]);
frame = getframe(1);
im = frame2im(frame); %pause(0.01);
[imind,cm] = rgb2ind(im,256);
imwrite(imind,cm,"C:\Users\ernika\wave_equation.gif",'gif'); %saved as mygif1
drawnow;
if(c~=2)
delete(my_plot)
end
end

Respuesta aceptada

Simon Chan
Simon Chan el 27 de Dic. de 2022
Check the answers from here

Más respuestas (0)

Categorías

Más información sobre Symbolic Math Toolbox 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