Here is an example of an object-oriented program in MATLAB:
main.m870 chars39 lines
In this example, a class Rectangle
is defined with two properties height
and width
. The class has a constructor to initialize the properties and two methods to calculate the area and perimeter of a rectangle.
Two objects r1
and r2
are created from the Rectangle
class using the constructor. The area
and perimeter
methods are called on these objects to calculate their respective values.
gistlibby LogSnag