0001 function [nfile] = fig2figs(fileformat,workdir,option,value)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023 if nargin == 0,
0024 fileformat = '*';
0025 workdir = pwd;
0026 end
0027 if nargin == 1,
0028 workdir = pwd;
0029 end
0030 if nargin == 3,
0031 error('Wrong number of input arguments in fig2figs.m');
0032 end
0033
0034 close all
0035
0036 filelist = dir('*.fig');
0037
0038 if strcmp(fileformat,'*'),fileformat = 'eps pdf jpg emf png';end
0039
0040 for ifile = 1:length(filelist),
0041
0042 open(filelist(ifile).name)
0043
0044 if strfind(fileformat,'eps'),
0045 if exist('option') == 1 & exist('value') == ifile,
0046 advexpfig(ifile,strtok(fullfile(workdir,filelist(ifile).name),'.'),'-depsc',option,value);
0047 else
0048 advexpfig(ifile,strtok(fullfile(workdir,filelist(ifile).name),'.'),'-depsc');
0049 end
0050 end
0051
0052 if strfind(fileformat,'pdf'),
0053 if exist('option') == 1 & exist('value') == 1,
0054 advexpfig(ifile,strtok(fullfile(workdir,filelist(ifile).name),'.'),'-dpdf ',option,value);
0055 else
0056 advexpfig(ifile,strtok(fullfile(workdir,filelist(ifile).name),'.'),'-dpdf ');
0057 end
0058 end
0059
0060 if strfind(fileformat,'jpg'),
0061 if exist('option') == 1 & exist('value') == 1,
0062 advexpfig(ifile,strtok(fullfile(workdir,filelist(ifile).name),'.'),'-djpeg ',option,value);
0063 else
0064 advexpfig(ifile,strtok(fullfile(workdir,filelist(ifile).name),'.'),'-djpeg ');
0065 end
0066 end
0067
0068 if strfind(fileformat,'emf'),
0069 if exist('option') == 1 & exist('value') == 1,
0070 if ~strfind(computer,'WIN'),
0071 advexpfig(ifile,strtok(fullfile(workdir,filelist(ifile).name),'.'),'-demf',option,value);
0072 end
0073 else
0074 if ~strfind(computer,'WIN'),
0075 advexpfig(ifile,strtok(fullfile(workdir,filelist(ifile).name),'.'),'-demf');
0076 end
0077 end
0078 end
0079
0080 if strfind(fileformat,'png'),
0081 if exist('option') == 1 & exist('value') == 1,
0082 advexpfig(ifile,strtok(fullfile(workdir,filelist(ifile).name),'.'),'-dpng',option,value);
0083 else
0084 advexpfig(ifile,strtok(fullfile(workdir,filelist(ifile).name),'.'),'-dpng');
0085 end
0086 end
0087 end
0088
0089 nfile = length(filelist);
0090
0091 close all
0092
0093