Before this, not much knowledge of object-oriented programming, let alone matlab object-oriented programming. However, in the first job experience still encountered a bit of use, but I was not very clear at that time. That was used to implement the use of the model in Simulink.
Today it's simple to do a class build and object creation. First implement the definition of a class, the code is as follows:
ClassDef person
Properties
Name
Age
Birth_year;
End
Methods
function obj = person (n,a,b)
Obj.name = n;
Obj.age = A;
Obj.birth_year = b;
End
function Show (obj)
DISP ([' Name: ', Obj.name]);
Disp ([' Age: ', Num2str (obj.age)]);
Disp ([' Birth_year: ', Num2str (obj.birth_year)]);
End
End
End
The definition of a class first needs to specify a keyword as the name of the class, and the following is divided into attributes and methods. Where the same function as the class name in the method is the constructor of the class. The use of classes is demonstrated as follows:
>> Tom = person (' Tom ', 10,2007)
Tom =
Person Withproperties:
Name: ' Tom '
Age:10
birth_year:2007
>> Tom.show ()
Name:tom
Age:10
birth_year:2007
By using this method, you can implement a method that creates an object through a class that has already been defined and invokes the object. Generally speaking, these methods are not very difficult. Later in the use, to see if you can live or work in the application of object-oriented technology in place.