Showing posts with label Matlab. Show all posts
Showing posts with label Matlab. Show all posts

Tuesday, 8 December 2020

Save a Matlab movie to an AVI file:

 Simple example script to save a Matlab movie to an AVI file:

Z = peaks;

surf(Z); 

axis tight manual 

set(gca,'nextplot','replacechildren'); 


v = VideoWriter('peaks.avi');

open(v);


for k = 1:20 

   surf(sin(2*pi*k/20)*Z,Z)

   frame = getframe(gcf);

   writeVideo(v,frame);

end


close(v);

Thursday, 6 March 2008

Movies in Matlab

This script shows the very basics on how to generate a movie in Matlab

% Generate a simple movie: plot f(t, x) = sin(x - t) on (0, 2pi) for different t

for i = 1:25

% Make a figure
t = 0.1 * i;
fplot(@(x) sin(x - t), [0 2*pi])

% Store the figure as a frame in the movie
M(i)=getframe;

end

% Play the movie ten times
movie(M,10)

Friday, 1 February 2008

Change Matlab-figures for print

If you use Matlab to generate EPS-files for inclusion in LaTeX-documents, you'll soon find that lines are too thin and text is too small. I use the following script to increase thickness and size in the current figure in Matlab:
linewidth = 2;
fontsize = 16;
fig = gcf;
h = findall(fig, 'Type', 'Text');
set(h, 'FontSize', fontsize)
h = findall(fig, 'Type', 'Axes');
set(h, 'FontSize', fontsize)
h = findall(fig, 'Type', 'Line');
set(h, 'LineWidth', linewidth)