How to create a gif?

조회 수: 4 (최근 30일)
Niloufar
Niloufar 2022년 12월 27일
답변: Simon Chan 2022년 12월 27일
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

채택된 답변

Simon Chan
Simon Chan 2022년 12월 27일
Check the answers from here

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Symbolic Math Toolbox에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by