When you use a quoted string as the first parameter to fminsearch then it needs to be the base name (without extension) of an executable file that is on your MATLAB path. It would typically name an m file such as f2.m but there are other possibilities
Y includes negative values. log() of negative is complex valued, so parts of your Z are complex valued. How would you like matlab to draw the contour of complex values?
Best Answer