function nma_generate_dep_files() %This function generates one text file for each m file it finds %in the same folder it is running from. For each m file it %finds, it generates the text file which contains a list of %the m files that the current m file depends on. % %This uses fdep() function from matlab central % %by Nasser M. Abbasi %feb 13, 2012 % list = dir('*.m'); addpath('../EXTERNAL/'); if isempty(list) fprintf('no matlab files found\n'); return end [SUCCESS,MESSAGE,MESSAGEID] = mkdir('..','depend'); if ~SUCCESS then fprintf('unable to make depend folder, %s\n',MESSAGE); return end for i=1:length(list) fprintf('processing %s\n',list(i).name) %create a txt file to write the dependecy into [fid,name_of_matlab_function] = open_file(list(i).name); %write the dependency into the file files_to_zip = write_dependency(fid,list(i).name); fclose(fid); % %make a zip file of the m file and any of its dependency p=dir([name_of_matlab_function '.fig']); if length(p)==1 files_to_zip =[p(1).name;files_to_zip]; end if strcmpi(name_of_matlab_function,'nma_poisson_GUI') files_to_zip =['nma_poisson_grid.png '; 'nma_poisson_step_black.png'; 'nma_poisson_play_black.png'; 'nma_poisson_stop_black.png'; 'nma_poisson_reset.jpg' files_to_zip]; end zip(['../depend/' name_of_matlab_function '.zip'],files_to_zip) end rmpath('../EXTERNAL/fdep_21jun2010'); end %----------------------------------------------------------- function [fid,name_of_matlab_function]=open_file(name) [pathstr, name_of_matlab_function, ext] = fileparts(name); new_name = ['../depend/' name_of_matlab_function '_DEP.txt']; [fid,message] = fopen(new_name,'w+t'); if fid==-1 error(sprintf('error opening %s, message is %s\n',new_name,message)); end [status,message]=copyfile(name,['../depend/' name '.txt']); if not(status ) error(sprintf('error copying %s, message is %s\n',name,message)); end end %------------------------------------------------------------- function deps=write_dependency(fid,name) fprintf(fid,'%s depends on: \n',name); fprintf(fid,'---------------------------------------------\n'); p = fdep(name,'-q'); for j=1:p.nfun-1 [pathstr, name_of_depends_file, ext] = fileparts(p.fun{j+1}); fprintf(fid,'%s\n',[name_of_depends_file '.m']); end deps=p.fun; end