saving = 0;  % set it to 1 if you want to save the pictures
lambda = linspace(1,3,51); % create the parameter space

x = linspace(0,4*pi);
c = 1; % initialize the counter
for la = lambda
  plot(x,sin(la*x))
  axis([0,4*pi,-1.2,1.2])
  if saving
    filename = sprintf('pic%03i.png',c);
    c = c+1;
    print(filename,'-dpng')
  endif
  usleep(0.1e6)
endfor

if saving
  system('avconv  -i ./pic%03d.png movie.mp4')
  system('rm -f *.png')
endif

