MATLAB: Does executing Example 2 for FMINSEARCH in MATLAB 7.0.1 (R14SP1) result in an error

MATLAB

When I execute the following code in Example 2 from the documentation for FMINSEARCH.
function f = myfun(x,a)
f = x(1)^2 + a*x(2)^2;
a = 1.5; % define parameter first
x = fminsearch(@(x) myfun(x,a),0,1)
I receive the following error:
Error Messages: ??? Attempted to access x(2); index out of bounds because numel(x)=1.

Best Answer

This change has been incorporated into the documentation in Release 14 Service Pack 3 (R14SP3). For previous releases, read below for any additional information:
This is an error in the documentation for MATLAB 7.0.1 (R14SP1) within the FMINSEARCH section. The documentation should read as follows:
x = fminsearch(@(x) myfun(x,a),[0 1]);
rather than:
x = fminsearch(@(x) myfun(x,a), 0, 1);