

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


Structures Structures are MATLAB arrays with named "data containers" called fields. The fields of a structure can contain any kind of data. For example, one field might contain a text string representing a name, another might contain a scalar representing a billing amount, a third might hold a matrix of medical test results, and so on. Like standard arrays, structures are inherently array oriented. A single structure is a 1-by-1 structure array, just as the value 5 is a 1-by-1 numeric array. You can build structure arrays with any valid size or shape, including multidimensional structure arrays. Cell arrays A cell array provides a storage mechanism for dissimilar kinds of data. This illustration shows a cell array A that contains arrays of unsigned integers in A{1,1}, strings in A{1,2}, complex numbers in A{1,3}, floating-point numbers in A{2,1}, signed integers in A{2,2}, and another cell array in A{2,3}. Cell arrays are most useful to store strings of different lengths. There is a difference between accessing a cell of a cell array, which uses (), and the data in this cell, which uses {}. Why do we not see this distinction in regular arrays? Note The notation {} denotes the empty cell array, just as [] denotes the empty matrix for numeric arrays. You can use the empty cell array in any cell array assignments. Cell Array Operators
Operation Syntax Description Constructing C = {A B D E} Builds a cell array C that can contain data of unlike types in A, B, D, and E Concatenating C3 = {C C2} Concatenates cell arrays C1 and C2 into a 2–element cell array C3 such that C3{1} = C1 and C3{2} = C C3 = [C C2] Concatenates the contents of cell arrays C1 and C Indexing X = C(s) Returns the cells of array C that are specified by subscripts s
X = C{s} (t) References one or more elements of an array that resides within a cell. Subscript s selects the cell, and subscript t selects the array element(s). Object Oriented Programming The programming we do in MATLAB is imperative ; we tell the computer what to do by giving it instructions. Data structure is something that is created as part of saying what to do. The major modern programming languages are object oriented : which puts the data (or object) first. Programming becomes the creation of Abstract Data Types (ADTs), which are often called classes. An ADT is simply a collection of data and operations that apply to it. A simple example is the stack, which has these operations push(x) add element x to stack pop () remove & return top element of stack isempty() true if the stash contains no elements MATLAB can support object oriented programming