OOP load update
Robert T. Short
octave at phaselockedsystems.com
Tue May 5 16:59:05 CDT 2009
Hello Wofgang,
Thanks for this information. MATLAB actually can reconstruct all of the
fields of the underlying struct from the mat file, but it is not able to
reconstruct inheritance from the mat file. Calling the constructor
seems like a natural way to do it, but MATLAB doesn't seem to ever call
the constructor when loading from a mat file.
In order to load a class with parent classes, you first need to
instantiate an object from the class constructor and then load the mat
file. This is now the way things work in octave, but I have been
thinking about invoking the class constructor to fill in the class
structure. As long as the constructor doesn't require arguments it
should work, but I haven't really thought it out that far yet.
Thanks again.
Bob
--
Robert T. Short
PhaseLocked Systems
WMennerich wrote:
> Hello,
> Matlab object loading using mat-files works like this:
> The zero-args-case in the constructor is only needed, if you want to load
> objects which class is not 'defined' within the current matlab session.
> 'Defined class' means here, that you have at least crated one object of the
> class, using the constructor with the NON-zero-args-case.
>
> The class stays 'defined', even if you delete all its objects.
>
> If you run 'clear classes', the knowledge about the class is away and you
> are no more able to load an object using a matfile if the constructor for
> that class has not a 'zero-args-case'.
>
> Matlab cares only about the first tier of fields of the classes because the
> content of these fields is not fixed. That means that
>
> a.b=0
> a.c=0
>
> and
>
>
> d.b.f=0
> d.c=0
>
> are two structures 'a' and 'd' which give the 'same' class in matlab
>
> Regards, Wolfgang
>
>
More information about the Octave-maintainers
mailing list