O'Reilly logo

Learning to Program with MATLAB: Building GUI Tools by Craig S. Lent

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

images

8.1   Cell arrays

8.2   Structures

8.3   Complex numbers

8.4   Function handles

8.5   Other data classes and data structures

We have already seen and used several classes of MATLAB data: double, representing real numbers; char, representing character data; and logical, representing Boolean data. Arrays can be formed from each of these. One-dimensional arrays of char we call “strings.”

v=-1.234;             % double vec=[1, 2.2, 4];      % vector of double M=[4, 1; 2, 1.2];     % 2D array of double = matrix keypressed='k';       % char myline='now go';      % 1D array of char = string CM=[ ['a', 'b']; ['c', 'd'] ]; % 2D array of char isDone=true;        % logical switchIsOn=[true, false, false, true]; % vector of logical isBig=(M>1);        % matrix of logical

There are several other MATLAB data classes that will prove useful. The first two are examples of heterogenous aggregation, that is, gathering information of different types together into one container, i.e., a MATLAB variable. Cell arrays are an extension of the by-now-familiar array idea to include different types of data as elements in the array. Structures, the class struct, aggregate different types of data that are labeled by names, rather than by indices. These would be more advanced topics we could differ to later but for the fact that a particular structure, called handles, plays a crucial role in managing GUI ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required