MATLAB: Am I unable to use a constructor which returns an array of objects using MATLAB 7.6 (R2008a)

MATLABmcosoop

I am using constructor in a class which returns an array of objects. I receive the following error when I create an object of this class:
??? Maximum recursion limit of 500 reached. Use set(0,'RecursionLimit',N)
to change the limit. Be aware that exceeding your available stack space can
crash MATLAB and/or your computer.
Error in ==> ArrayTest>ArrayTest.ArrayTest
I am following the syntax available at the following link:
<http://www.mathworks.com/access/helpdesk/help/techdoc/matlab_oop/brd4btr.html>

Best Answer

The constructor calls itself recursively with no arguments when the second row of objects is created.
To work around the issue, see the following example:
classdef ArrayTest < handle
properties
Quantity
end
methods
function t = ArrayTest(m,n)
if nargin == 0
return
end
for i = 1:m
for j = 1:n
t(i,j).Quantity = rand(10);
end
end
end
end
end
There is no workaround to create a no argument constructor which returns an array of objects.