% emitmov    

    makemov = 1 ;
    fnum = figure ;

    if makemov == 1
        mov = avifile('/Users/jolly/Desktop/emitplot.avi','fps',25,'compression','None') ;
    end

    figure(fnum), hold off ;
    set(fnum,'color','white') ;
    xlabel(['x (mm)']), ylabel(['x'' (mrad)']) ;
    axis([-25 25 -150 150]) ; axis square ;
    jpgplot(fnum) ;

    if makemov == 1
        frame(i) = getframe(fnum) ;
        mov = addframe(mov,frame(i)) ;
    end

    x = timemat(1).x.*1000 ;
    xp = timemat(1).xp.*1000 ;
    numpart = length(x) ;
    low1 = [1:1:100] ;
    low2 = [101:10:991] ;
    low3 = [1001:50:numpart-49] ;
    lowlim = [low1 low2 low3] ;
    highlim = [low1 low2+9 low3+49] ;
    numloops = length(lowlim) ; %+ 500 ;

    for i = 1:numloops

        figure(fnum), hold on ;

        plot(x(lowlim(i):highlim(i)),xp(lowlim(i):highlim(i)),'xk') ;

        if makemov == 1
            frame(i) = getframe(fnum) ;
            mov = addframe(mov,frame(i)) ;
        end

    end

    if makemov == 1
        mov = close(mov) ;
    end

    return