Prev: How do i include an average and 90% confidence in plot?
Next: calculating mean and standard deviation of pixels in images
From: Richard on 8 Apr 2010 11:26 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 8 Apr 2010 16:55 "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 9 Apr 2010 06:48
"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.... |