Como criar um gif animado em matlab



%Após leitura dos arquivos

h = figure;
axis tight manual % Isto garante que getframe() retorne um tamanho consistente
filename = 'nomedoarquivo.gif';

for n = 1:1:27 % gif com 27 imagens
   
    if n == 1
        subplot(221); imagesc(x, y, v(n) ,); title("Modelo Inicial")
        subplot(222); imagesc(x, y, v(n) ,); title("Modelo Final") 
    else
        subplot(221); imagesc(x, y, v(n) ,); title("Modelo Inicial")
        subplot(222); imagesc(x, y, v(n) ,); title("Modelo Final") 

    end
    drawnow

      % Capture os plots com uma imagem
      frame = getframe(h);
      im = frame2im(frame);
      [imind,cm] = rgb2ind(im,256);

      % Escreve o arquivo gif
      if n == 1
          imwrite(imind,cm,filename,'gif', 'Loopcount',inf);
      else
          imwrite(imind,cm,filename,'gif','WriteMode','append');
      end
   

end

Comentários