Making_A_Movie

Making_A_Movie - graphical capabilities. Suppose for...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
CS 111 - Introduction to Computational Science Making a movie in Matlab The following code describes how to make a movie in Matlab. Comments start with a %. % Get a figure: fig=figure; % Create a movie file called ‘‘example.avi’’ (the format is .avi): aviobj = avifile(‘example.avi’) for k=1:Number_of_Frames % Number_of_Frames is an integer you define. plot_commands % Put all of your plot commands here. % Get the frame: F = getframe(fig); % Append the frame to the movie: aviobj = addframe(aviobj,F); end % Close things as usual: close(fig) aviobj = close(aviobj); Loading Files in Matlab Let us assume that we use C++ to do our computations, but that we still want to use Matlab’s
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: graphical capabilities. Suppose for example that want to plot y as a function of x . Assume that we save the data from C++ in a le called My_File.dat with the following format: 0 2 .3 2.5 .6 4.2 .9 5.9 ... i.e. the rst column refers to the x s and the second column refers to the corresponding y s. The following Matlab commands will be used to plot y versus x : load My_File.dat; % Load the file into Matlab. x=My_File(:,1); % Assign x to be the first column of the file. y=My_File(:,2); % Assign y to be the second column of the file. plot(x,y); % Plot y as a function of x. 1...
View Full Document

Ask a homework question - tutors are online