Home > utility > isFunction.m

isFunction

PURPOSE ^

isFunction: Test is the given M-file is a function

SYNOPSIS ^

function output = isFunction(filename);

DESCRIPTION ^

 isFunction: Test is the given M-file is a function

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function output = isFunction(filename);
0002 % isFunction: Test is the given M-file is a function
0003 
0004 %    Roger Jang, 20030712
0005 
0006 if nargin<1; selfdemo; return; end
0007 
0008 fid=fopen(filename);
0009 line=fgetl(fid);
0010 fclose(fid);
0011 
0012 start=regexp(line, '^function');
0013 output=0;
0014 if ~isempty(start)
0015     output=1;
0016 end
0017 
0018 % ===== Self demo
0019 function selfdemo
0020 fileName='isFunction.m';
0021 output=feval(mfilename, 'isFunction.m');
0022 if output
0023     fprintf('The given M-file "%s" is a function.', fileName);
0024 else
0025     fprintf('The given M-file "%s" is not a function.', fileName);
0026 end

Generated on Tue 01-Jun-2010 09:50:34 by m2html © 2003