Code covered by the BSD License  

Highlights from
intent.m

image thumbnail

intent.m

by

 

Graphically display mfiles, and naive intent

intent(mfiles)
function A = intent(mfiles)
%INTENT - Graphically display mfile input and output arguments, and naive intent 
%
% INTENT creates a plot of relationships between mfiles in the current
% directory, as infered by the names of input and output arguments. 
%
% INTENT(DIR) creates a plot for a user provided directory
%
% INTENT(MFILES) creates a plot for a user supplied list of mfiles supplied as a cell array MFILES
%
% A = INTENT(MFILES) returns an adjacency matrix. An edge A(j,k) is set to 1 if any output argument of MFILES{j} has the same name
% as any of MFILES{k}'s input arguments.  
%
%DEPENDENCIES
%  Bioinformatics toolbox
%  functor.m 
%  signature.m 
%
%Peter Cotton
 
%% Allow user to supply nothing
% Reveal intention of nFunc-files in current directory
if nargin<1,
   mfiles = cd;
end
 
%% Allow user to supply a directory name
if ischar(mfiles) && isdir(mfiles),
   w = what(mfiles);   
   mfiles = w.m;      % listing of nFunc-files in current directory 
end
 
%% Allow user to supply char instead of function_handle
nFunc = length(mfiles);
F = cell(nFunc,1);
for k=1:nFunc,
    in_ = signature.argin(mfiles{k});
    out_ = signature.argout(mfiles{k});
    name_ = fixName(mfiles{k});
    dummy_ = @(x) 1;  % We don't need the function handle
    F{k} = functor(dummy_,in_,out_,name_);
end
 
%% Display
A = functor.view(F{:});


    function name = fixName(name)
        if name(1)=='@',
            name = name(2:end);
        end
        if strcmpi(name(end-1:end),'.m'),
            name = name(1:end-2);
        end
    end




end

Contact us