Skip to main content
Library homepage
 
Engineering LibreTexts

17.3: Object-Oriented Programming

  • Page ID
    86412
  • \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \) \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)\(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\) \(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\)\(\newcommand{\AA}{\unicode[.8,0]{x212B}}\)

    Object-Oriented Programming is an important concept in modern programming.

    It is what distinguishes C++ from the C programming language.

    The fundamentals concepts are:

    * Definition of data classes (types)

    * Storage of data classes

    * Methods (functions) that implement operation on each data class.

    MATLAB uses this approach hidden from the user. When variables, vectors and arrays are created, Matlab keeps track of the data type and size/dimensions. Number types include character string or number, floating-point or integer, single or double precision, real or complex. Most of its routines can handle scalars, vectors, and arrays, without the typical user needing to know the details that are under the covers.

    MATLAB also allows the user to define his/her own objects with the object's data type and routines. An example is a "student" data type that has character string data, such as name, major, and contact info. It also has numerical data such as number of credits passed in each general education area and in the dstudent's major.

    A short tutorial on Object-Oriented Programming in MATALB is given in this on-line course:

    MATLAB: An Introductory Course (Links to an external site.)

    You can get to the Object-Oriented tutorial by clicking on the "Table of Contents" tab, then selecting "Object-Oriented Programming (OOP)". Or you can search of "Object-Oriented Programming". It's about 85% of the way down the page.

    Here are more links for Matlab's Object-Oriented capabilities:

    Introduction to Object-Oriented Programming in MATLAB (Links to an external site.)

    Object-Oriented Programming in Matlab examples


    This page titled 17.3: Object-Oriented Programming is shared under a CC BY-NC-SA 4.0 license and was authored, remixed, and/or curated by Carey Smith.

    • Was this article helpful?