|
"Steven_Lord" <slord@mathworks.com> wrote in message <jt6ppi$il6$1@newscl01ah.mathworks.com>...
>
>
> "Yuheng " <e2_71828@tom.com> wrote in message
> news:jt5ksk$ck7$1@newscl01ah.mathworks.com...
> > Hi,
> > First time I use a class in matlab, I have met a problem in the
> > initialization of object arrays.
> > Is there any function like zeros or repmat to initialize any user
> > defined class, or need I to write a function for each class I used
> > separately?
> > I find the function class can be used to convert a structure array to
> > object array, but it seems not available in a classdef block.
>
> Are you using a class that someone else wrote, or are you writing your own
> class?
>
> If the latter, have you read through this section of the documentation? It
> describes how to handle creation and manipulation of object arrays in your
> class.
>
> http://www.mathworks.com/help/techdoc/matlab_oop/brd4btr.html
>
> If the former, it depends on how the class was implemented. REPMAT should
> work to replicate a scalar object into an array (unless the author of the
> class specifically disallowed that.)
>
> --
> Steve Lord
> slord@mathworks.com
> To contact Technical Support use the Contact Us link on
> http://www.mathworks.com
I am writing my own class, and the link is really helpful. I did not take the case nargin=0 into account, after modified that, repmat works.
Thanks a lot!
|