23.06.2015 Views

MATLAB Programming

MATLAB Programming

MATLAB Programming

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

2 Data Types<br />

Operation Syntax Description<br />

Concatenating<br />

Indexing<br />

C3 = {C1 C2}<br />

C3 = [C1 C2]<br />

X = C(s)<br />

X = C{s}<br />

X = C{s}(t)<br />

Concatenates cell arrays C1 and C2 into a<br />

2–element cell array C3 such that C3{1} =<br />

C1 and C3{2} = C2<br />

Concatenates the contents of cell arrays<br />

C1 and C2<br />

Returns the cells of array C that are<br />

specified by subscripts s<br />

Returns the contents of the cells of C that<br />

are specified by subscripts s<br />

References one or more elements of an<br />

array that resides within a cell. Subscript<br />

s selects the cell, and subscript t selects<br />

the array element(s).<br />

Creating a Cell Array<br />

Creating cell arrays in <strong>MATLAB</strong> is similar to creating arrays of other<br />

<strong>MATLAB</strong> data types like double, character,etc.Themaindifferenceisthat,<br />

when constructing a cell array, you enclose the array contents or indices with<br />

curly braces { } instead of square brackets [ ]. The curly braces are cell<br />

array constructors, just as square brackets are numeric array constructors.<br />

Use commas or spaces to separate elements and semicolons to terminate<br />

each row.<br />

For example, to create a 2-by-2 cell array A, type<br />

A = {[1 4 3; 0 5 8; 7 2 9], 'Anne Smith'; 3+7i, -pi:pi/4:pi};<br />

This results in the array shown below:<br />

2-96

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!