MATLAB Programming

MATLAB Programming MATLAB Programming

cda.psych.uiuc.edu
from cda.psych.uiuc.edu More from this publisher
23.06.2015 Views

2 Data Types ans = 7 ans = 2 ans = 9 ans = 2 Note that MATLAB returns a comma-separated list. To have MATLAB return thelistofelementsasavectorinstead, surround the previous expression with square brackets: [A{2,2}{3,:}] ans = 7 2 9 2 Plotting the Cell Array For a high-level graphical display of cell architecture, use the cellplot function. Consider a 2-by-2 cell array containing two text strings, a matrix, and a vector: c{1,1} = '2-by-2'; c{1,2} = 'eigenvalues of eye(2)'; c{2,1} = eye(2); c{2,2} = eig(eye(2)); The command cellplot(c) produces this figure: 2-106

Cell Arrays Deleting Cells You can delete an entire dimension of cells using a single statement. Like standard array deletion, use vector subscripting when deleting a row or column of cells and assign the empty matrix to the dimension: A(cell_subscripts) = [] When deleting cells, curly braces do not appear in the assignment statement at all. Reshaping Cell Arrays Like other arrays, you can reshape cell arrays using the reshape function. The number of cells must remain the same after reshaping; you cannot use reshape to add or remove cells: A = cell(3, 4); size(A) ans = 2-107

2 Data Types<br />

ans =<br />

7<br />

ans =<br />

2<br />

ans =<br />

9<br />

ans =<br />

2<br />

Note that <strong>MATLAB</strong> returns a comma-separated list. To have <strong>MATLAB</strong> return<br />

thelistofelementsasavectorinstead, surround the previous expression<br />

with square brackets:<br />

[A{2,2}{3,:}]<br />

ans =<br />

7 2 9 2<br />

Plotting the Cell Array<br />

For a high-level graphical display of cell architecture, use the cellplot<br />

function. Consider a 2-by-2 cell array containing two text strings, a matrix,<br />

and a vector:<br />

c{1,1} = '2-by-2';<br />

c{1,2} = 'eigenvalues of eye(2)';<br />

c{2,1} = eye(2);<br />

c{2,2} = eig(eye(2));<br />

The command cellplot(c) produces this figure:<br />

2-106

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

Saved successfully!

Ooh no, something went wrong!