From: Richard on
Hi, I would like to be able to generate(approx 100) objects of a user defined class using a loop.I this possible or is there a better way?
From: Rich Ellis on

"Richard " <REMOVETHISrcaldwellie(a)yahoo.com> wrote in message
news:hpksiv$smb$1(a)fred.mathworks.com...
> Hi, I would like to be able to generate(approx 100) objects of a user
> defined class using a loop.I this possible or is there a better way?

Perhaps adapt your constructor to produce an array. Something similar to
this (See "Object Arrays" in the MATLAB documentation).

classdef DocArrayExample
properties
Value
end
methods
function obj = DocArrayExample(F)
if nargin ~= 0 % Allow nargin == 0 syntax
m = size(F,1);
n = size(F,2);
obj(m,n) = DocArrayExample; % Preallocate object array
for i = 1:m
for j = 1:n
obj(i,j).Value = F(i,j);
end
end
end
end
end
end


From: Richard on
"Rich Ellis" <rich(a)mathworks.com> wrote in message <hplft2$rt6$1(a)fred.mathworks.com>...
>
> "Richard " <REMOVETHISrcaldwellie(a)yahoo.com> wrote in message
> news:hpksiv$smb$1(a)fred.mathworks.com...
> > Hi, I would like to be able to generate(approx 100) objects of a user
> > defined class using a loop.I this possible or is there a better way?
>
> Perhaps adapt your constructor to produce an array. Something similar to
> this (See "Object Arrays" in the MATLAB documentation).
>
> classdef DocArrayExample
> properties
> Value
> end
> methods
> function obj = DocArrayExample(F)
> if nargin ~= 0 % Allow nargin == 0 syntax
> m = size(F,1);
> n = size(F,2);
> obj(m,n) = DocArrayExample; % Preallocate object array
> for i = 1:m
> for j = 1:n
> obj(i,j).Value = F(i,j);
> end
> end
> end
> end
> end
> end
>

Thanks V. much. Looks like a possible solution to my problem....