• Search
  • Register
  • Log in
  • The Math Root » Matlab
  • HOWTO: Creating movies with Matlab
  •  
    Anil

    If you want to show how your plots change with time, a movie is a good idea. Especially since MATLAB can produce movies that can be embedded in your presentations, or be seen with any good ol' movie player. Here's how:

    The idea is to create plot figures and compile them as frames of your movie.

    % Create a new figure, and position it
        fig1 = figure;
        winsize = get(fig1,'Position');
        winsize(1:2) = [0 0];
    % Create movie file with required parameters
        fps= 25;
        outfile = sprintf('%s',outFileName)
        mov = avifile(outfile,'fps',fps,'quality',100);
    % Ensure each frame is of the same size
        set(fig1,'NextPlot','replacechildren');
        for i=1:numframes
            plot(x,y); % generate your plot
    % put this plot in a movieframe
    % In case plot title and axes area are needed
    %       F = getframe(fig1,winsize);
    % For clean plot without title and axes
            F = getframe;
            mov = addframe(mov,F);
         end
    % save movie
        mov = close(mov);

    Voila! (Make sure that you do not open any window over your plot window while MATLAB is compiling your movie, else those windows will become part of your movie)

    #7
    Anil
    Member
    Posted 1 year ago
    RSS feed for this topic  

    Reply

    You must log in to post.

      Tags:

  •  © 2009 Anil Kandangath. All posts are owned by the whoever posted them. Share your knowledge.
    The Math Root is proudly powered by bbPress.. This site is not affiliated with The MathWorks™ or Wolfram Research. //   Theme by Mike Lothar  
    [ Time : 0.161s | 8 Queries ]