1

For OO programming we use classdef in matlab. Could someone explain to me how could I access the super class ? What is the role of properties, are they like constructors in Java?

chappjc
  • 30,359
  • 6
  • 75
  • 132
lola
  • 5,649
  • 11
  • 49
  • 61
  • I hate to be the grumpy old man, but you clearly didn't even google your questions. You'll get much more helpful answers if you put in some effort. – Marc Mar 12 '12 at 19:34

2 Answers2

3

Use @ to access the superclass. From Calling Superclass Methods on Subclass Objects:

classdef MySub < MySuperClass
   methods
      function obj = MySub(arg1,arg2,...)
         obj = obj@MySuperClass(SuperClassArguments);
            ...
      end % MySub
   end % methods
end % classdef

Properties are like member variables. Properties – Storing Class Data.

Richie Cotton
  • 118,240
  • 47
  • 247
  • 360
  • obj = obj@MySuperClass(SuperClassArguments); here to access to super class ,but how do can I access to any methods ? the @ is used to call a function declared in a function ? – lola Mar 13 '12 at 07:39
  • 1
    It sounds like you have lots of introductory questions on classes. The best thing for you to do now would be to read the MathWorks documentation and try some examples. If you still don't understand, then ask again. – Richie Cotton Mar 13 '12 at 10:43
2

To define a subclass you could look at the documentation

Single inheritance:

classdef classname < superclassname

For multiple inheritance:

classdef classname < super1 & super2

Properties are more like instance variables in Java.

macduff
  • 4,655
  • 18
  • 29