The FEVAL command is supported by the MATLAB Compiler and may be called implicitly within a command such as the following:
deg= leastsq('objFun',deg,[],[],A,Dx1period);
LEASTSQ is a "function function." These functions--which include the ODE solvers, minimization routines, and numerical integration routines--take a function name as an argument. The MATLAB Compiler does not know objFun.m is a function that is being passed to LEASTSQ, so it does not compile this function along with the rest of the files that it sees being explicitly called in your program. Consequently the executable code for objFun cannot be found at runtime.
You can work around this problem in one of two ways, both involve telling the Compiler to compile the additional file. The first way to do this is to include the file on the compilation line:
mcc -m myMain.m -a objFun.m
The other method is to use the "%#function" pragma in one of the files of your application. It is a good idea to do this in the files which use the objective function in question, so your code would become
function deg=myfile(Key,Dx,degInit)
deg= leastsq('objFun',deg,[],[],A,Dx1period);
To compile the application now, you need only type
For a more complete description of what happens with FEVAL in compiled code, see page 5-65 of the MATLAB Compiler User's Guide.