9

Structures in Matlab

Chapter Outline

Lesson 9.1 Structures in Matlab

Lesson 9.2 A Vector of Structures

Answers to Selected Exercises

Project: The Fox and Rabbit Game

Lesson 9.1 Structures in Matlab

Objectives

• To learn how to construct a structure in Matlab.

• To learn how to write a structure function in Matlab.

Topics

9.1.1 The Need for the Structure Class

9.1.2 Functions for Structures

9.1.1 The Need for the Structure Class

You have studied vectors and arrays in this book. You can use the vectors and arrays to save a collection of identical classes. For example, the vector x saves a collection of numbers with the double class, as shown below:

In this second example, the array Y saves a collection of numbers with the logical class.

In ...

Get MATLAB® by Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.