Animated Gif mit Matlab erstellen: Unterschied zwischen den Versionen

Aus HSHL Mechatronik
Zur Navigation springen Zur Suche springen
Keine Bearbeitungszusammenfassung
Keine Bearbeitungszusammenfassung
Zeile 22: Zeile 22:




 
== Ergebnis ==
[[Datei:AnimatedGif.gif]]
----
----
→ zurück zum Hauptartikel: [[Einführung_in_MATLAB|Einführung in MATLAB]]
→ zurück zum Hauptartikel: [[Einführung_in_MATLAB|Einführung in MATLAB]]

Version vom 30. Mai 2014, 09:24 Uhr

x = 0:0.01:1;
% Grafik erstellen
figure(1)
% Dateiname festlegen
filename = 'AnimatedGif.gif';
% 2 fps
for n = 1:0.5:5
      y = x.^n;
      plot(x,y)
      drawnow
      frame = getframe(1);
      im = frame2im(frame);
      [imind,cm] = rgb2ind(im,256);
      if n == 1;
          imwrite(imind,cm,filename,'gif', 'Loopcount',inf);
      else
          imwrite(imind,cm,filename,'gif','WriteMode','append');
      end
end


Ergebnis


→ zurück zum Hauptartikel: Einführung in MATLAB