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.

Cell Arrays<br />

billing<br />

test<br />

In assignments, you can use content indexing to access only a single cell, not a<br />

subset of cells. For example, the statements A{1,:} = value and B = A{1,:}<br />

are both invalid. However, you can use a subset of cells any place you would<br />

normally use a comma-separated list of variables (for example, as function<br />

inputs or when building an array). See “Replacing Lists of Variables with<br />

Cell Arrays” on page 2-108 for details.<br />

Assigning Cells. For cell indexing, assign the double array cell to X:<br />

X = A(1,1)<br />

X =<br />

[3x5 double]<br />

X isa1-by-1cellarray:<br />

whos X<br />

Name Size Bytes Class<br />

X 1x1 180 cell<br />

For content indexing, assign the contents of the first cell of row 1 to Y:<br />

Y = A{1,1}<br />

Y =<br />

19.0026 9.7196 9.1294 8.8941 18.4363<br />

4.6228 17.8260 0.3701 12.3086 14.7641<br />

12.1369 15.2419 16.4281 15.8387 3.5253<br />

Y is a 3-by-5 double array<br />

whos Y<br />

Name Size Bytes Class<br />

Y 3x5 120 double<br />

Assigning Multiple Cells. Assigning multiple cells with cell indexing is<br />

similar to assigning a single cell. <strong>MATLAB</strong> creates a new cell array, each cell<br />

of which contains a cell array.<br />

2-103

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

Saved successfully!

Ooh no, something went wrong!