MATLAB Mathematics - SERC - Index of
MATLAB Mathematics - SERC - Index of MATLAB Mathematics - SERC - Index of
6 Sparse Matrices The find Function and Sparse Matrices For any matrix, full or sparse, the find function returns the indices and values of nonzero elements. Its syntax is [i,j,s] = find(S) find returns the row indices of nonzero values in vector i, the column indices in vector j, and the nonzero values themselves in the vector s. The example below uses find to locate the indices and values of the nonzeros in a sparse matrix. The sparse function uses the find output, together with the size of the matrix, to recreate the matrix. [i,j,s] = find(S) [m,n] = size(S) S = sparse(i,j,s,m,n) 6-16
Adjacency Matrices and Graphs Adjacency Matrices and Graphs This section includes: • An introduction to adjacency matrices • Instructions for graphing adjacency matrices with gplot • A Bucky ball example, including information about using spy plots to illustrate fill-in and distance • An airflow model example Introduction to Adjacency Matrices The formal mathematical definition of a graph is a set of points, or nodes, with specified connections between them. An economic model, for example, is a graph with different industries as the nodes and direct economic ties as the connections. The computer software industry is connected to the computer hardware industry, which, in turn, is connected to the semiconductor industry, and so on. This definition of a graph lends itself to matrix representation. The adjacency matrix of an undirected graph is a matrix whose (i,j)th and (j,i)th entries are 1 if node i is connected to node j, and 0 otherwise. For example, the adjacency matrix for a diamond-shaped graph looks like A = 1 0 1 0 1 1 0 1 0 0 1 0 1 1 0 1 0 2 4 Since most graphs have relatively few connections per node, most adjacency matrices are sparse. The actual locations of the nonzero elements depend on how the nodes are numbered. A change in the numbering leads to permutation 3 6-17
- Page 206 and 207: 5 Differential Equations Finding Un
- Page 208 and 209: 5 Differential Equations vectorized
- Page 210 and 211: 5 Differential Equations There is a
- Page 212 and 213: 5 Differential Equations 3 Solve on
- Page 214 and 215: 5 Differential Equations hold off T
- Page 216 and 217: 5 Differential Equations Note The d
- Page 218 and 219: 5 Differential Equations legend('An
- Page 220 and 221: 5 Differential Equations Here, v(1-
- Page 222 and 223: 5 Differential Equations solution v
- Page 224 and 225: 5 Differential Equations Note The D
- Page 226 and 227: 5 Differential Equations After disc
- Page 228 and 229: 5 Differential Equations The output
- Page 230 and 231: 5 Differential Equations 2 Code the
- Page 232 and 233: 5 Differential Equations Note See t
- Page 234 and 235: 5 Differential Equations The exampl
- Page 236 and 237: 5 Differential Equations and the ri
- Page 238 and 239: 5 Differential Equations u1(x,t) 1
- Page 240 and 241: 5 Differential Equations Selected B
- Page 242 and 243: 6 Sparse Matrices Function Summary
- Page 244 and 245: 6 Sparse Matrices Function Summary
- Page 246 and 247: 6 Sparse Matrices This matrix requi
- Page 248 and 249: 6 Sparse Matrices S = (3,1) 1 (2,2)
- Page 250 and 251: 6 Sparse Matrices Now F = full(S) d
- Page 252 and 253: 6 Sparse Matrices Importing Sparse
- Page 254 and 255: 6 Sparse Matrices west0479 west0479
- Page 258 and 259: 6 Sparse Matrices of the rows and c
- Page 260 and 261: 6 Sparse Matrices The vertices of o
- Page 262 and 263: 6 Sparse Matrices 0 10 20 30 40 50
- Page 264 and 265: 6 Sparse Matrices 0 500 1000 1500 2
- Page 266 and 267: 6 Sparse Matrices simply sparse(m,n
- Page 268 and 269: 6 Sparse Matrices Similarly, S(:,p)
- Page 270 and 271: 6 Sparse Matrices The following MAT
- Page 272 and 273: 6 Sparse Matrices 0 Original 0 Reve
- Page 274 and 275: 6 Sparse Matrices QR Factorization
- Page 276 and 277: 6 Sparse Matrices shows that A has
- Page 278 and 279: 6 Sparse Matrices Functions for Ite
- Page 280 and 281: 6 Sparse Matrices set up the five-p
- Page 282 and 283: 6 Sparse Matrices Manipulating Spar
- Page 284 and 285: 6 Sparse Matrices Selected Bibliogr
- Page 286 and 287: Index comparing sparse and full mat
- Page 288 and 289: Index H hb1dae demo 5-35 hb1ode dem
- Page 290 and 291: Index nonstiff ODE examples rigid b
- Page 292 and 293: Index LU factorization 6-30 minimum
- Page 294: Index twobvp demo 5-63 two-dimensio
6 Sparse Matrices<br />
The find Function and Sparse Matrices<br />
For any matrix, full or sparse, the find function returns the indices and values<br />
<strong>of</strong> nonzero elements. Its syntax is<br />
[i,j,s] = find(S)<br />
find returns the row indices <strong>of</strong> nonzero values in vector i, the column indices<br />
in vector j, and the nonzero values themselves in the vector s. The example<br />
below uses find to locate the indices and values <strong>of</strong> the nonzeros in a sparse<br />
matrix. The sparse function uses the find output, together with the size <strong>of</strong> the<br />
matrix, to recreate the matrix.<br />
[i,j,s] = find(S)<br />
[m,n] = size(S)<br />
S = sparse(i,j,s,m,n)<br />
6-16