0% found this document useful (0 votes)
66 views12 pages

Object Oriented Programming in Matlab: Richard E. Turner (Rt60@nyu - Edu) November 29th, 2011

This document discusses object oriented programming in MATLAB. It introduces common object oriented programming concepts and jargon like classes, objects, properties, methods, encapsulation, inheritance and polymorphism. It provides examples of how these concepts can be applied to create object oriented code in MATLAB, such as defining classes for different probability distributions and their relationships. The document also lists several resources for learning more about object oriented programming in MATLAB.

Uploaded by

Er Rajesh Bura
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
66 views12 pages

Object Oriented Programming in Matlab: Richard E. Turner (Rt60@nyu - Edu) November 29th, 2011

This document discusses object oriented programming in MATLAB. It introduces common object oriented programming concepts and jargon like classes, objects, properties, methods, encapsulation, inheritance and polymorphism. It provides examples of how these concepts can be applied to create object oriented code in MATLAB, such as defining classes for different probability distributions and their relationships. The document also lists several resources for learning more about object oriented programming in MATLAB.

Uploaded by

Er Rajesh Bura
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

Object oriented programming in matlab

Richard E. Turner ([email protected]) November 29th, 2011

Our goals in life...


unit tests test the code write bug free quickly version control write small units reuse the code clearly written easy to add/modify

object oriented

Jargon

object properties methods data-fields functions

Matlab simile: like a structure with pre-dened, xed elds

Jargon

object properties methods data-fields functions

un-normalised Gaussian natural parameters compute moments

Matlab simile: like a structure with pre-dened, xed elds

Jargon

class un-normalised Gaussian data-fields functions natural parameters compute moments

object properties methods

Matlab simile: like a structure with pre-dened, xed elds

Object oriented approach

Organises data and functions which belong together Abstracts so others can operate at the level of the objects (programming = creating abstractions) Data-forward thinking (rather than code forward) you think about the data rst. OO makes simpler programs more complicated, but complex ones more simple. Beware too much/forced abstraction. There is an overhead

How does it do this: Encapsulation and property access

object

properties

dependent properties

get methods

How does it do this: Encapsulation and property access

un-normalised Gaussian

object

natural parameters

moments

properties

dependent properties

moment computation

get methods

How does it do this: Inheritance and dynamic dispatch

un-normalised Gaussian
natural parameters compute moments

un-normalised Gamma
natural parameters compute moments

un-normalised isotropic Gaussian


natural parameters compute moments

dynamic dispatch e.g. exact moment computation methods

How does it do this: Inheritance and dynamic dispatch


un-normalised exponential family

inherit e.g. pdf methods un-normalised Gaussian


natural parameters compute moments

un-normalised Gaussian un-normalised isotropic Gaussian


natural parameters compute moments

un-normalised Gamma
natural parameters compute moments

dynamic dispatch e.g. exact moment computation methods

Example

Where to nd out more information


Lorens blog: When to use OO: http://blogs.mathworks.com/loren/2008/08/18/ when-to-create-classes-in-matlab/ Design considerations for OO: http://blogs.mathworks.com/loren/2011/ 03/08/common-design-considerations-for-object-properties/

Tutorial for matlab OO: http://www.mathworks.com/company/newsletters/articles/introduction-t html Software carpentry introduction: http://software-carpentry.org/4_0/oop/intro/

Online video tutorial: http://www.mathworks.com/products/demos/shipping/matlab/WhatsNewR200 ObjectOrientedProgramming.html

You might also like