%% ngif.m %% Loop For making pictures % A function of two variables, described in Matlab help. % The output is 20x20 matrix of Z values % Output filename (a frame number will be appended in the loop) nam=input('enter the name of the new fileset : ','s'); % Total number of frames nfram=input('enter the number of frames : '); fprintf(1,'\n\nTo avoid problems with colormaps, close Netscape and similar\n '); fprintf(1,'\nAdjust the figure size and place it visibly on screen !!\n '); fprintf(1,'Select this command window and hit RETURN\n '); fff=peaks(20); mesh(fff); % Test figure shown for adjustment set(gcf,'menubar','none') % Remove menubar set(gcf,'color',[1 1 1]) % Make frame white set(gcf,'numbertitle','off') % No figure number set(gcf,'name','MATANIM') % Identify the window by a unique name set (gcf,'colormap',[0 0 0; 0 0 0]) % all drawing BLACK pause % The main loop for kfram=1:nfram % Viewing angle alf=30-10*kfram; % Plot the 3D mesh mesh(fff); % Change the viewing angle view( alf ,30); % Flush pending graphics events drawnow; % Create xwd file with current picture. Filenames all start with % the string specified in variable nam. Then the frame number is appended % followed by '.xwd' extension. Note that frame numbers must have the % same number of charecters for proper sorting of filenames. This is % achived by adding 100 to the frame number. % % This routine is using the X-window dump function xwd eval( [ '! xwd -name "MATANIM " -out ' nam num2str(100+kfram) '.xwd' ] ) % Convert XWD file into JPEG file with the same filename but different % extension ('.jpeg'). eval( [ '! convert -monochrome ' nam num2str(100+kfram) '.xwd ' ... nam num2str(100+kfram) '.jpeg' ] ) % eval( ' ! rm -f *.xwd '); % Convert JPEG into grayscaled GIF. eval( [ '! djpeg -colors 2 -grayscale -gif ' ... nam num2str(100+kfram) '.jpeg > ' nam num2str(100+kfram) '.gif' ] ) % The end of main loop end % Merge all GIF files into an animation GIF file. eval( [ '! Gifmerge -5 -l0 ' nam '*.gif ' ' > anim' nam '.gif' ] ) % Remove all temporary files. eval( [ '! rm -f ' nam '*.jpeg ' nam '*.eps ' nam '*.gif ' ] )