Animation, MATLAB in Mathematics


In this part we will observe a couple of ways to animate a plot. These are visuals, therefore the outcomes can't really be shown here; it is essential to type these into a MATLAB to view the results.

We begin by animating a plot of sin(x) with the vectors:

>> x = -2*pi : 1/100 : 2*pi;

>> y = sin(x);

This results in sufficient points that we will be able to view the result by using the built-in comet function, that shows the plot by first displaying the point (x(1),y(1)), and then moving on to the point (x(2),y(2)), and so forth, leaving a trail of all the earlier points.

   >> comet(x,y)

The final result looks similar as plot(x,y).

The other way of animating is to use the built-in function movie that shows recorded movie frames. The frames are captured in a loop by using the built-in function getframe, and are stored in the matrix. For illustration, the script below again animates the sin function. The axis function is used so that the MATLAB will use similar set of axes for all frames, and by using the min and max functions on the data vectors x & y will permit us to see all points.

It shows movie once in the for loop, and then again whenever the movie function is called.


Posted Date: 10/22/2012 1:51:45 AM | Location : United States

Related Discussions:- Animation, Assignment Help, Ask Question on Animation, Get Answer, Expert's Help, Animation Discussions

Write discussion on Animation
Your posts are moderated
Related Questions
Logical Vectors: The relational operators can also be used with the vectors and matrices. For illustration, let's say that there is a vector, and we want to compare each eleme

Plot types: Besides plot and bar, there are another plot types like stem plots, histograms, stem plots, area plots and pie charts, and also other functions which customize the

Illustration of Empty vectors: The Empty vectors can also be used to delete elements from the arrays. For illustration, to remove the third element from array, an empty vector

User-defined functions: Therefore, although many functions compute and return values, some do not. A few functions rather merely accomplish a task. Regardless of what type of

Plot Functions: Faraway, we have plotted to generate two-dimensional plots and bar to generate bar charts. We have seen how to clear the Figure Window by using clf, and how to

Illustration of Spreadsheet Files: This reads the numbers in a double vector variable nums and the text in a cell array txt (the xlsread function forever returns the numbers f

Illustration of Variance For illustration, for the vector [4, 6, 1, 5], there are n = 4 values therefore n - 1 is 3. The mean of this data set is also 4. The variance will be

Empty Vectors: An empty vector or in another words, a vector which stores no values, can be generated using the empty square brackets: >> evec = [] evec = [] >> lengt

Common form of the switch statement: The common form of the switch statement is as shown below:   switch switch_expression   case caseexp1    action1   case cas

Dimensions - matrix: The size and length functions in the MATLAB are used to find array dimensions. Length function returns the number of elements in the vector. The size func