MATLAB and Simulink Training

Object-Oriented Programming with MATLAB

View schedule and enroll

Course Details

Maintaining a large collection of MATLAB functions can be challenging because any change to the data format causes wide-spread, error-prone updates in the existing code. Object-oriented programming addresses these issues by grouping data and related functions into a single unit, defining a custom data type. Furthermore, it allows hiding implementation details from a user, thus simplifying future modifications and improving maintainability.

In this course, you will learn object-oriented programming techniques to develop complex yet flexible MATLAB® applications. Additionally, you will discover how to implement unit testing to guarantee software quality and ensure easy maintenance. Topics include:
 
  • Creating custom data types that group data and functions together
  • Creating maintainable and extensible applications via inheritance and aggregation
  • Making applications reliable and flexible with unit tests
  • Automatically triggering functions upon data changes

Day 1 of 2


Creating Custom Data Types

Objective: Learn basic techniques and experience the differences between procedural and object-oriented programming. Create a simple custom data type known as a class.

  • Grouping data and functionality into a single class definition file
  • Documenting classes
  • Using classes to create workspace variables known as objects

Designing a MATLAB Class

Objective: Design an easy-to-use class that prevents data inconsistencies. Hide implementation details from the user to achieve easy maintenance and a simple user interface.

  • Utilizing property attributes and access methods to create an intuitive class that prevents data inconsistencies.
  • Hiding implementation details through private properties and methods
  • Customizing standard operators for the class

Building Class Hierarchies

Objective: Avoid code duplication by creating a common superclass to contain the shared functionality of several similar classes.

  • Creating a common superclass for two similar classes
  • Extending the superclass through a subclass and implementing specialized behavior
  • Using abstract properties and methods when data and functions cannot be fully defined on the superclass level

Day 2 of 2


Facilitating Multiple References

Objective: Ensure data consistency by using reference (handle) behavior to share a single data object throughout the application. Extend the functionality of a class by embedding it into another class through aggregation.

  • Creating a class that exhibits reference behavior
  • Embedding a data class into a viewer class responsible for data visualization
  • Choosing between pass-by-reference and the usual pass-by-value behavior

Writing Unit Tests

Objective: Improve code maintainability by creating unit tests that ensure correct code behavior. Use the MATLAB unit-testing framework to enhance the quality and flexibility of your software.

  • Writing a unit test
  • Creating a test environment using setup and teardown methods
  • Parameterizing tests
  • Testing for error conditions
  • Aggregating and running suites of tests
  • Creating test coverage reports

Synchronizing Objects

Objective: Automatically trigger function calls in response to specific data changes. Determine which data changes to monitor and which functions to execute by utilizing events, listeners, and callbacks.

  • Use events to specify data changes that need to be monitored
  • Define listeners which trigger reactions to event
  • Implement callbacks specifying code to be executed as a reaction

Level: Intermediate

Prerequisites:

Duration: 2 days

Languages: Deutsch, English, 日本語, 한국어

View schedule and enroll