Code covered by the BSD License  

Highlights from
depfun2

from depfun2 by Daniel Ennis
This function allows one to reduce to results of DEFUN through the use of a keyword.

G=depfun2(fname,keyword,varargin);
% DEPFUN2 finds the M-file dependencies of an m-file whos
% path also contains a KEYWORD.  It relies upon the use of the 
% DEPFUN function.  DEPFUN2 accepts a keyword to 'grep' for allowing 
% the return of m-files that are only found on a specific path (a users 
% path for example).  The keyword (or part of a word) is used to find 
% matches in the full pathname of all files that the m-file depends upon.
%
% SYNTAX: G=depfun2(fname);
%         G=depfun2(fname,[]);
%         G=depfun2(fname,keyword);
%         G=depfun2(fname,keyword,varargin);
%
% fname    - The name of the m-file for which to determine dependencies
% keyword  - The keyword used to retain m-files whose pathname contains 'keyword'
%            DEFAULT keyword is unix('whoami') on UNIX platforms.
% varargin - Any of the various arguments that DEPFUN usually accepts.
%
% Example: G=depfun2('bench','graphics','-quiet','-toponly'); % Returns FEWER results than...
%          G=depfun2('bench','graphics','-quiet');            % Because this includes indirectly called m-files
% 
%
%          On Unix Platforms the DEFAULT of:
%            G=depfun2(fname);
%          Is equivalent to:
%            [STATUS,USERNAME]=unix('whoami');
%            G=depfun2(fname,deblank(USERNAME),'-quiet');
%
% DBE 2003/02/07
% DBE 2004/10/26 Modified to support full range of DEPFUN inputs.
% DBE 2005/07/29 Modified to use unix('whoami') as DEFAULT keyword.
% DBE 2005/09/29 Fixed bug when using 2 input arguments
% DBE 2006/04/11 Fixed bug noted by TMW user regarding the inputs.  Cleaned up the code and commented more.

function G=depfun2(fname,keyword,varargin);
if (nargin <2 | isempty(keyword)) & isunix
  [status,keyword]=unix('whoami');
  keyword=deblank(keyword);
  if status
    error('UNIX WHOAMI call failed.');
  end
elseif nargin<2
  error('depfun2.M requires at least two user inputs on non-UNIX platforms');
end

if nargin>2  % VARARGIN can be used to pass standard arguments to DEPFUN
  % Concatentate the VARARGIN into a string that can be used with DEPFUN
  input=[];
  for n=1:length(varargin)
    input=[input,'''',varargin{n},''''];
    if n~=length(varargin), input=[input,',']; end
  end
else  % Default input argument to DEPFUN
%   input=['''','-quiet','''',',','''','-toponly',''''];  % This restricts tracing to first level
  input=['''','-quiet',''''];
end

T=eval(['depfun(fname,',input,');']);

G=[]; m=1;
for k=1:length(T)
  f=strfind(T{k},keyword);
  if ~isempty(f), 
    G{m}=T{k};
    m=m+1; 
  end
end

G=G';

return

Contact us at files@mathworks.com