MATLAB Programming
MATLAB Programming MATLAB Programming
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
- Page 156 and 157: 2 Data Types Valid Syntax Invalid S
- Page 158 and 159: 2 Data Types A = 'fate'; B = 'cake'
- Page 160 and 161: 2 Data Types while (any(remainder))
- Page 162 and 163: 2 Data Types Converting from String
- Page 164 and 165: 2 Data Types Function Summary MATLA
- Page 166 and 167: 2 Data Types Functions to Determine
- Page 168 and 169: 2 Data Types Date Strings There are
- Page 170 and 171: 2 Data Types • The day field is a
- Page 172 and 173: 2 Data Types datestr(d) ans = 01-Ma
- Page 174 and 175: 2 Data Types Utility Functions (Con
- Page 176 and 177: 2 Data Types • “Applying Functi
- Page 178 and 179: 2 Data Types where the arguments ar
- Page 180 and 181: 2 Data Types You can access subarra
- Page 182 and 183: 2 Data Types Dynamic Field Names Ex
- Page 184 and 185: 2 Data Types Deleting Fields from S
- Page 186 and 187: 2 Data Types plot(mercury, 'b') plo
- Page 188 and 189: 2 Data Types There are at least two
- Page 190 and 191: 2 Data Types Element-by-element org
- Page 192 and 193: 2 Data Types Nesting Structures A s
- Page 194 and 195: 2 Data Types Cell Arrays A cell arr
- Page 196 and 197: 2 Data Types Operation Syntax Descr
- Page 198 and 199: 2 Data Types 3-by-3 Cell Array Note
- Page 200 and 201: 2 Data Types C5 = 'Jan' 'Feb' 'Mar'
- Page 202 and 203: 2 Data Types of an array without re
- Page 204 and 205: 2 Data Types Createa1-by-2arraywith
- Page 208 and 209: 2 Data Types 3 4 B = reshape(A, 6,
- Page 210 and 211: 2 Data Types A{1,1} = [1 2; 3 4]; A
- Page 212 and 213: 2 Data Types [5x5 double] {2x2 cell
- Page 214 and 215: 2 Data Types G = cell(1,16); for m
- Page 216 and 217: 2 Data Types Function Handles A fun
- Page 218 and 219: 2 Data Types MATLAB Classes All MAT
- Page 220 and 221: 2 Data Types 2-120
- Page 222 and 223: 3 Basic Program Components Symbol R
- Page 224 and 225: 3 Basic Program Components Note If
- Page 226 and 227: 3 Basic Program Components Another
- Page 228 and 229: 3 Basic Program Components Verifyin
- Page 230 and 231: 3 Basic Program Components function
- Page 232 and 233: 3 Basic Program Components Evaluati
- Page 234 and 235: 3 Basic Program Components Keywords
- Page 236 and 237: 3 Basic Program Components Hereares
- Page 238 and 239: 3 Basic Program Components Operator
- Page 240 and 241: 3 Basic Program Components To test
- Page 242 and 243: 3 Basic Program Components Function
- Page 244 and 245: 3 Basic Program Components 5 11 10
- Page 246 and 247: 3 Basic Program Components Advantag
- Page 248 and 249: 3 Basic Program Components MATLAB E
- Page 250 and 251: 3 Basic Program Components This M-f
- Page 252 and 253: 3 Basic Program Components • “S
- Page 254 and 255: 3 Basic Program Components Operator
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