Graphics

Example - Visualizing an FFT as a Movie

This example illustrates the use of movies to visualize the quantity `fft(eye(n))`, which is a complex n-by-n matrix whose elements are various powers of the `n`th root of unity, `exp(i*2*pi/n)`.

Creating the Movie

Create the movie in a `for` loop calling `getframe` to capture the graph. Since the `plot` command resets the axes properties, call `axis` `equal` within the loop before `getframe`.

• ``````for k = 1:16
``````    plot(fft(eye(k+16)))
``````    axis equal
``````    M(k) = getframe;
``````end
``````

Running the Movie

After generating the movie, you can play it back any number of times. To play it back 30 times, type

• ```movie(M,30)
```

You can readily generate and smoothly play back movies with a few dozen frames on most computers. Longer movies require large amounts of primary memory or a very effective virtual memory system.

Movies that Include the Entire Figure

If you want to capture the contents of the entire figure window (for example, to include GUI components in the movie), specify the figure's handle as an argument to the `getframe` command. For example, suppose you want to add a slider to indicate the value of `k` in the previous example.

• ```h = uicontrol('style','slider','position',...
[10 50 20 300],'Min',1,'Max',16,'Value',1)
for k = 1:16
plot(fft(eye(k+16)))
axis equal
set(h,'Value',k)
M(k) = getframe(gcf);
end
```

In this example, the movie frame contains the entire figure. To play so that it looks like the original figure, make the playback axes fill the figure window.

• ```clf
axes('Position',[0 0 1 1])
movie(M,30)
```

 Movies Erase Modes