|
"M " <aflopb-mat@yahoo.de> wrote in message <hntaul$2p5$1@fred.mathworks.com>...
> I want to merge some procedural Matlab code to OO-Code.
>
> I first started with creating and @-folder and have accomplished in writing a simple contructor and subsref method (both working as expected). The class is an aggregation of objects of the same kind from another class A and some extra parameters.
>
> Now I found out that it is also possible to define a class in a single file with a classdef-block. I would prefer to do it that way. So I copied the code form the class-folder to the classdef-file. But now when creating an object of the class I get an object that contains the parameters as expected, but the cell array that should contain the objects of class A containse also cell arrays that contain cellarrays ....
>
> My question is: Why does Matlab has these two ways in defining a class and what are the differences.
=========
The two methods exist because the one using @-directories was the former way and has been replaced in later MATLAB editions by classdef files. @-directories are still available for backward compatibility.
Note also that the @-directory and classdef file approaches are not mutually exclusive. You can define a class using classdef inside a @-directory. This allows you to put class methods in separate files if you wish to.
The classdef approach has a lot of new capabilities over the old style. There are many differences between the two approaches but none of them, I don't think, explain the problem you are describing. To understand that, we would need to see actual code/examples.
|