NCCOOS Trac Projects: Top | Web | Platforms | Processing | Viz | Sprints | Sandbox | (Wind)

root/gliderproc/trunk/MATLAB/util/fpeval.m

Revision 495 (checked in by cbc, 11 years ago)

Initial import of Stark code.

Line 
1 function [varargout] = fpeval(theFcn, varargin)
2
3 % fpeval -- FEVAL by full-path name.
4 %  [...] = fpeval('theFcn', ...) performs FEVAL with
5 %   'theFcn' function, given by its full-path name,
6 %   exclusive of extension.  Use this routine to
7 %   execute functions that lie outside the Matlab
8 %   path, including those hidden in "private"
9 %   areas.
10 %  [...] = fpeval({theFcnParts}, ...) will use the
11 %   Matlab "fullfile" function to construct theFcn
12 %   from a list of its part-names.  For example,
13 %   {matlabroot, 'toolbox', 'signal', 'private',
14 %   'chi2conf'} will reach the private chi-square
15 %   confidence routine in the "signal" toolbox.
16  
17 % Copyright (C) 1998 Dr. Charles R. Denham, ZYDECO.
18 %  All Rights Reserved.
19 %   Disclosure without explicit written consent from the
20 %    copyright owner does not constitute publication.
21  
22 % Version of 02-Nov-1998 09:43:22.
23
24 if nargin < 1, help(mfilename), return, end
25
26 if iscell(theFcn)
27         theFcn = fullfile(theFcn{:});
28 end
29
30 % Separate directory and function names.
31
32 originalFcn = theFcn;
33
34 thePWD = pwd;
35 theDir = '';
36 f = find(theFcn == filesep);
37 if any(f)
38         theDir = theFcn(1:f(end));
39         theFcn(1:f(end)) = '';
40 end
41
42 % Trim extension, if any.
43
44 f = find(theFcn == '.');
45 if any(f), theFcn(f(1):end) = ''; end
46
47 % Change directory, then execute.
48
49 try
50         if ~isempty(theDir), cd(theDir), end
51         if nargout > 0
52                 varargout = cell(1, nargout);
53                 [varargout{:}] = feval(theFcn, varargin{:});
54         else
55                 feval(theFcn, varargin{:});
56         end
57 catch
58         disp([' ## ' mfilename ' -- An error occurred while attempting:'])
59         disp([' ## "' originalFcn '"'])
60         disp([' ## ' lasterr])
61 end
62
63 % Restore directory, no matter what.
64
65 if ~isempty(theDir), cd(thePWD), end
Note: See TracBrowser for help on using the browser.