DOC PREVIEW
GT AE 6382 - Object Oriented Programming in Matlab

This preview shows page 1-2-3 out of 10 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 10 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 10 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 10 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 10 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Object Oriented Programming in MatlabObject-Oriented ProgrammingWhat is OOPMatlab and OOPWhat is an Object?What is an Object - cont’dExamplesMatlab’s Built-in ClassesSummary…SummaryFall 2006AE6382 Design Computing 1Object Oriented Programming in Matlab•Intro to Object-Oriented Programming (OOP)•An example that creates a ASSET class and shows how it might be used•Extend the ASSET class to subclasses of STOCKS, BONDS and SAVINGS.Learning ObjectivesWe’re now going to introduce you to some advanced computing concepts, and we’ll illustrate a simple application that creates a new data type called an ASSET with subtypes.TopicsFall 2006AE6382 Design Computing 2Object-Oriented Programming•Object-oriented programming has become a focus of computer science in recent years…–Simula67, SmallTalk, Objective C, C++ and Java are OOP languages–OOP is a key part of the first CS courses•OOP keeps you from getting into certain kinds of treacherous problems and tends to foster more reliable coding practices–stimulates a modular coding approach–allows you to hide details from inadvertent alterations–lets you create a hierarchical code structure–But often leads to complex and confusing class librariesFall 2006AE6382 Design Computing 3What is OOP•OOP is part of an on-going effort to add more discipline and organization to programming–it is incorporated to varying degrees in a number of languages–Matlab incorporates OOP •While the basic OOP concept is simple, the practical execution can often seem lost in many details! •The 4 fundamental OOP characteristics–Abstraction: refine away unimportant details and describe an object by only the data that is important to the task at hand.–Encapsulation: operations must be tightly associated with the data on which they can operate–Inheritance: a hierarchical structure can be effectively employed to describe data and the operations on it–Polymorphism: using the same name to refer to similar methods to handle different kinds of dataFall 2006AE6382 Design Computing 4Matlab and OOP•Matlab makes extensive use of OOP at all levels of its design and construction…–much of the basic user programming touches on parts of this but most is well-hidden (to retain the original power of the language)–but it is accessible to programmers when needed–see Chapter 33 in MM7 and Matlab>Programming>Classes & Objects in online help docs•We’re going to go over only the very basics of OOP in Matlab–you can pursue more details on your own (in Matlab or Java…)–we’ll illustrate OOP concepts by examining how Matlab’s Handle Graphics can be used to extend its plotting and visualization capabilities.Fall 2006AE6382 Design Computing 5What is an Object?•Objects (physical or not) have properties and behaviors–Car: Properties = color, speed, fuel consumption, HP…Behaviors = start, stop, turning…–Triangle: Properties = area, perimeter, linestyle, location…Behaviors = translate, rotate, shrink, flip…–Date : Properties = year, month, day…Behaviors = SetDate, getMonth, isGreater…–Employee: Properties = SSN, age, gender, …Behaviors = setName, getLastname, calcPay…•Properties: information about the object•Behaviors: methods to set, get and process propertiesFall 2006AE6382 Design Computing 6What is an Object - cont’d•OOP lets us create: –a data type –along with the set of operations that can be performed on this data type–this helps us avoid using wrong operations on given data and getting meaningless results•A Class:–description of the structure of the new data type (called fields)–the set of operations (called methods or functions) defined for this data type•An Object:–a variable having a specific class–Matlab has certain built-in classes–but you can easily define your ownFall 2006AE6382 Design Computing 7Examples•Sometimes the differences between classes and objects gets confusing…•Example 1:–House plans: the architectural drawings that describe how a house is to be constructed are a House Class–A house: the house built from the plans is an Object or an Instance of the House Class; the process of building the house is called Instantiation of the class. Note that by changing some of the dimensions (fields or properties), one can create a new house object from the same class (plans).•Example 2:–Flowchart: provides the plans for a program (the Class)–Program: written from the flowchart is an instance of the class (an object)Fall 2006AE6382 Design Computing 8Matlab’s Built-in Classes•Matlab’s built-in classes:–others in additional Toolboxes•You can define your own Matlab classes:–data structure (the fields) is a Matlab struct–methods (functions) are stored in special directory (@classname) that is a subdirectory of a directory in the Matlab path–a constructor is a method that is used to create an object (an instance of a class)char NUMERIC javaclasscell functionhandleint8, uint8,int16, uint16,int32, uint32single doublesparseuser classstructureARRAYFall 2006AE6382 Design Computing 9Summary…•OOP will let us create an entirely new data types in Matlab–this is done by creating a class to define this data type–we must also create all the methods (functions) that can be used with this special data type–the internal details are hidden inside the class•What could we do with this new class?–some engineering functions require use of special data sets and associated methods: this is a good application and you will find this in some of the toolboxes–we can define subclasses to create a data hierarchy–we’ll look further into this in the next lecture•We’ll also look closely at operator overloading, especially for Matlab’s basic classesFall 2006AE6382 Design Computing 10Summary Action Items•Review the lecture•Consult the reference material•Consider how this might be extended to other applicationsLearning Objectives•OOP


View Full Document

GT AE 6382 - Object Oriented Programming in Matlab

Download Object Oriented Programming in Matlab
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Object Oriented Programming in Matlab and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Object Oriented Programming in Matlab 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?