Opening the book…
An ordinary MATLAB array is usually homogeneous. Homogeneous means that all elements in the array have the same general type. For example, the following vector is a numeric array because every value is numeric:
scores = [87 92 78 95 88]
Likewise, this string array stores text values:
days = ["Monday" "Tuesday" "Wednesday"]
A heterogeneous collection contains different types of information together. For example, a student record may include a first name, a last name, a student ID number, and a GPA. That is a mix of text and numbers. MATLAB provides several ways to work with heterogeneous data. In this chapter we focus on:
- Cell arrays
- Structures
- Arrays of structures
- Tables
The table below summarizes the typical uses and examples of each data type.
|
Data organization |
Typical use |
Example |
|
Numeric array |
Same type of numeric data |
Temperatures, forces, voltages |
|
String array |
Same type of text data |
Names of cities or files |
|
Cell array |
Mixed data stored by position |
A row containing ID, make, model, mileage |
|
Structure |
Mixed data stored by field name |
student.FirstName, student.ID, student.GPA |
|
Structure array |
Many similar records |
One structure per student, car, part, or sensor |
|
Table |
Mixed data stored by named columns |
Spreadsheet-style data such as student records or lab measurements |
This page titled 8.3: Review- Homogeneous and Heterogeneous Data was last modified on Tue, 30 Jun 2026 02:12:01 GMT and is shared under a CC BY-NC-SA license and was authored, remixed, and/or curated by Zara Noroozi.
The book could not be loaded just now.