MATLAB: Does DocExtendDouble example produce an error while using subscripted assignment

MATLAB

I am trying the example on the documentation page for "Example — Adding Properties to a Built-In Subclass" found by typing the following at the MATLAB Command Prompt:
web([docroot '/techdoc/matlab_oop/brgze9_-1.html#brrpjb7'])
Or by navigating to the following URL:
<http://www.mathworks.com/access/helpdesk/help/techdoc/matlab_oop/brgze9_-1.html#brrpjb7>
I have made the class definition file for DocExtendDouble.
When I execute the following commands:
ed = DocExtendDouble(1:10,'One to ten');
ed(1:5) = 5:-1:1
I get the following error:
??? Input argument "str" is undefined.
Error in ==> DocExtendDouble>DocExtendDouble.DocExtendDouble at 14
obj.DataString = str;

Best Answer

This change has been incorporated into the documentation in Release 2009a (R2009a). For previous releases, read below for any additional information:
This behavior is a bug in the class definition file provided in the documentation for "Example — Adding Properties to a Built-In Subclass". When the command
ed(1:5) = 5:-1:1
is executed, the constructor for the DocExtendDouble class gets called. The constructor does not find the expected second argument called "str" of type string, and thus produces the error.
As a workaround, replace the constructor for the DocExtendDouble class definition with the following:
function obj = DocExtendDouble(data,str)
if nargin == 0
data = [];
elseif nargin < 2
str = '';
end
obj = obj@double(data);
obj.DataString = str;
end