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 />

3–by-3 Cell Array<br />

Note If you already have a numeric array of a given name, don’t try to<br />

create a cell array of the same name by assignment without first clearing<br />

the numeric array. If you do not clear the numeric array, <strong>MATLAB</strong> assumes<br />

that you are trying to “mix” cell and numeric syntaxes, and generates an<br />

error. Similarly, <strong>MATLAB</strong> does not clear a cell array when you make a single<br />

assignment to it. If any of the examples in this section give unexpected<br />

results, clear the cell array from the workspace and try again.<br />

Alternative Assignment Syntax. When assigning values to a cell array,<br />

either of the syntaxes shown below is valid. You can use the braces on the<br />

right side of the equation, enclosing the value being assigned as shown here:<br />

A(1,1) = {[1 4 3; 0 5 8; 7 2 9]};<br />

A(1,2) = {'Anne Smith'};<br />

Or use them on the left side, enclosing the array subscripts:<br />

A{1,1} = [1 4 3; 0 5 8; 7 2 9];<br />

A{1,2} = 'Anne Smith';<br />

2-98

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

Saved successfully!

Ooh no, something went wrong!