www.gusucode.com > mbcdata 工具箱 matlab 源码程序 > mbcdata/@cgoptim/checkFunctionFile.m
function [status, msg] = checkFunctionFile(optim) %CHECKFUNCTIONFILE Check the status of the function file % % [STATUS, MSG] = CHECKFUNCTIONFILE(OPTIM) returns a status code and a % message that indicate the status of the selected function file for the % optimization. % % STATUS contains an integer code indicating whether the function is in an % acceptable state. A status of 0 indicates no problem, 1 indicates a % warning issue and 2 indicates an critical problem. MSG is a string that % describes the problem and should be non-empty for a non-zero status. % Copyright 2005 The MathWorks, Inc. and Ford Global Technologies, Inc. status = 0; msg = ''; % Check that we can still find the optimisation script. We call which % using a string input to ensure that we do not pick up inaccessible % object methods. scriptinfo = which([optim.fname '('''')']); if isempty(scriptinfo) status = 2; msg = sprintf('Unable to locate file %s on the MATLAB path', optim.fname); else % Check the file for syntax errors by setting a breakpoint (if there % is'nt one already) s = dbstatus(optim.fname); if isempty(s) try dbstop('in', optim.fname); dbclear('in', optim.fname); catch status = 2; msg = sprintf('Optimization function %s contains a MATLAB syntax error', optim.fname); end end end