## c Coefficient for `specifyCoefficients`

### Overview of the c Coefficient

This topic describes how to write the coefficient `c` in equations such as

`$m\frac{{\partial }^{2}u}{\partial {t}^{2}}+d\frac{\partial u}{\partial t}-\nabla ·\left(c\nabla u\right)+au=f$`

The topic applies to the recommended workflow for including coefficients in your model using `specifyCoefficients`.

For 2-D systems, `c` is a tensor with 4N2 elements. For 3-D systems, `c` is a tensor with 9N2 elements. For a definition of the tensor elements, see Definition of the c Tensor Elements. N is the number of equations, see Equations You Can Solve Using PDE Toolbox.

To write the coefficient `c` for inclusion in the PDE model via `specifyCoefficients`, give `c` as either of the following:

• If `c` is constant, give a column vector representing the elements in the tensor.

• If `c` is not constant, give a function handle. The function must be of the form

`ccoeffunction(location,state)`

`solvepde` or `solvepdeeig` pass the `location` and `state` structures to `ccoeffunction`. The function must return a matrix of size N1-by-Nr, where:

• N1 is the length of the vector representing the `c` coefficient. There are several possible values of N1, detailed in Some c Vectors Can Be Short. For 2-D geometry, 1 ≤ N1 ≤ 4N2, and for 3-D geometry, 1 ≤ N1 ≤ 9N2.

• Nr is the number of points in the location that the solver passes. Nr is equal to the length of the `location.x` or any other `location` field. The function should evaluate `c` at these points.

### Definition of the c Tensor Elements

For 2-D systems, the notation $\nabla \cdot \left(c\otimes \nabla u\right)$ represents an N-by-1 matrix with an (i,1)-component

`$\sum _{j=1}^{N}\left(\frac{\partial }{\partial x}{c}_{i,j,1,1}\frac{\partial }{\partial x}+\frac{\partial }{\partial x}{c}_{i,j,1,2}\frac{\partial }{\partial y}+\frac{\partial }{\partial y}{c}_{i,j,2,1}\frac{\partial }{\partial x}+\frac{\partial }{\partial y}{c}_{i,j,2,2}\frac{\partial }{\partial y}\right){u}_{j}$`

For 3-D systems, the notation $\nabla \cdot \left(c\otimes \nabla u\right)$ represents an N-by-1 matrix with an (i,1)-component

`$\begin{array}{l}\sum _{j=1}^{N}\left(\frac{\partial }{\partial x}{c}_{i,j,1,1}\frac{\partial }{\partial x}+\frac{\partial }{\partial x}{c}_{i,j,1,2}\frac{\partial }{\partial y}+\frac{\partial }{\partial x}{c}_{i,j,1,3}\frac{\partial }{\partial z}\right){u}_{j}\\ +\sum _{j=1}^{N}\left(\frac{\partial }{\partial y}{c}_{i,j,2,1}\frac{\partial }{\partial x}+\frac{\partial }{\partial y}{c}_{i,j,2,2}\frac{\partial }{\partial y}+\frac{\partial }{\partial y}{c}_{i,j,2,3}\frac{\partial }{\partial z}\right){u}_{j}\\ +\sum _{j=1}^{N}\left(\frac{\partial }{\partial z}{c}_{i,j,3,1}\frac{\partial }{\partial x}+\frac{\partial }{\partial z}{c}_{i,j,3,2}\frac{\partial }{\partial y}+\frac{\partial }{\partial z}{c}_{i,j,3,3}\frac{\partial }{\partial z}\right){u}_{j}\end{array}$`

All representations of the `c` coefficient begin with a “flattening” of the tensor to a matrix. For 2-D systems, the N-by-N-by-2-by-2 tensor flattens to a 2N-by-2N matrix, where the matrix is logically an N-by-N matrix of 2-by-2 blocks.

`$\left(\begin{array}{ccccccccc}c\left(1,1,1,1\right)& c\left(1,1,1,2\right)& & c\left(1,2,1,1\right)& c\left(1,2,1,2\right)& & \cdots & c\left(1,N,1,1\right)& c\left(1,N,1,2\right)\\ c\left(1,1,2,1\right)& c\left(1,1,2,2\right)& & c\left(1,2,2,1\right)& c\left(1,2,2,2\right)& & \cdots & c\left(1,N,2,1\right)& c\left(1,N,2,2\right)\\ & & & & & & & & \\ c\left(2,1,1,1\right)& c\left(2,1,1,2\right)& & c\left(2,2,1,1\right)& c\left(2,2,1,2\right)& & \cdots & c\left(2,N,1,1\right)& c\left(2,N,1,2\right)\\ c\left(2,1,2,1\right)& c\left(2,1,2,2\right)& & c\left(2,2,2,1\right)& c\left(2,2,2,2\right)& & \cdots & c\left(2,N,2,1\right)& c\left(2,N,2,2\right)\\ & & & & & & & & \\ ⋮& ⋮& & ⋮& ⋮& & \ddots & ⋮& ⋮\\ c\left(N,1,1,1\right)& c\left(N,1,1,2\right)& & c\left(N,2,1,1\right)& c\left(N,2,1,2\right)& & \cdots & c\left(N,N,1,1\right)& c\left(N,N,1,2\right)\\ c\left(N,1,2,1\right)& c\left(N,1,2,2\right)& & c\left(N,2,2,1\right)& c\left(N,2,2,2\right)& & \cdots & c\left(N,N,2,1\right)& c\left(N,N,2,2\right)\end{array}\right)$`

For 3-D systems, the N-by-N-by-3-by-3 tensor flattens to a 3N-by-3N matrix, where the matrix is logically an N-by-N matrix of 3-by-3 blocks.

`$\left(\begin{array}{cccccccccccc}c\left(1,1,1,1\right)& c\left(1,1,1,2\right)& c\left(1,1,1,3\right)& & c\left(1,2,1,1\right)& c\left(1,2,1,2\right)& c\left(1,2,1,3\right)& & \cdots & c\left(1,N,1,1\right)& c\left(1,N,1,2\right)& c\left(1,N,1,3\right)\\ c\left(1,1,2,1\right)& c\left(1,1,2,2\right)& c\left(1,1,2,3\right)& & c\left(1,2,2,1\right)& c\left(1,2,2,2\right)& c\left(1,2,2,3\right)& & \cdots & c\left(1,N,2,1\right)& c\left(1,N,2,2\right)& c\left(1,N,2,3\right)\\ c\left(1,1,3,1\right)& c\left(1,1,3,2\right)& c\left(1,1,3,3\right)& & c\left(1,2,3,1\right)& c\left(1,2,3,2\right)& c\left(1,2,3,3\right)& & \cdots & c\left(1,N,3,1\right)& c\left(1,N,3,2\right)& c\left(1,N,3,3\right)\\ & & & & & & & & & & & \\ c\left(2,1,1,1\right)& c\left(2,1,1,2\right)& c\left(2,1,1,3\right)& & c\left(2,2,1,1\right)& c\left(2,2,1,2\right)& c\left(2,2,1,3\right)& & \cdots & c\left(2,N,1,1\right)& c\left(2,N,1,2\right)& c\left(2,N,1,3\right)\\ c\left(2,1,2,1\right)& c\left(2,1,2,2\right)& c\left(2,1,2,3\right)& & c\left(2,2,2,1\right)& c\left(2,2,2,2\right)& c\left(2,2,2,3\right)& & \cdots & c\left(2,N,2,1\right)& c\left(2,N,2,2\right)& c\left(2,N,2,3\right)\\ c\left(2,1,3,1\right)& c\left(2,1,3,2\right)& c\left(2,1,3,3\right)& & c\left(2,2,3,1\right)& c\left(2,2,3,2\right)& c\left(2,2,3,3\right)& & \cdots & c\left(2,N,3,1\right)& c\left(2,N,3,2\right)& c\left(2,N,3,3\right)\\ ⋮& ⋮& ⋮& & ⋮& ⋮& ⋮& & \ddots & ⋮& ⋮& ⋮\\ c\left(N,1,1,1\right)& c\left(N,1,1,2\right)& c\left(N,1,1,3\right)& & c\left(N,2,1,1\right)& c\left(N,2,1,2\right)& c\left(N,2,1,3\right)& & \cdots & c\left(N,N,1,1\right)& c\left(N,N,1,2\right)& c\left(N,N,1,3\right)\\ c\left(N,1,2,1\right)& c\left(N,1,2,2\right)& c\left(N,1,2,3\right)& & c\left(N,2,2,1\right)& c\left(N,2,2,2\right)& c\left(N,2,2,3\right)& & \cdots & c\left(N,N,2,1\right)& c\left(N,N,2,2\right)& c\left(N,N,2,3\right)\\ c\left(N,1,3,1\right)& c\left(N,1,3,2\right)& c\left(N,1,3,3\right)& & c\left(N,2,3,1\right)& c\left(N,2,3,2\right)& c\left(N,2,3,3\right)& & \cdots & c\left(N,N,3,1\right)& c\left(N,N,3,2\right)& c\left(N,N,3,3\right)\end{array}\right)$`

These matrices further get flattened into a column vector. First the N-by-N matrices of 2-by-2 and 3-by-3 blocks are transformed into "vectors" of 2-by-2 and 3-by-3 blocks. Then the blocks are turned into vectors in the usual column-wise way.

The coefficient vector `c` relates to the tensor c as follows. For 2-D systems,

`$\left(\begin{array}{ccccccccc}c\left(1\right)& c\left(3\right)& & c\left(4N+1\right)& c\left(4N+3\right)& & \cdots & c\left(4N\left(N-1\right)+1\right)& c\left(4N\left(N-1\right)+3\right)\\ c\left(2\right)& c\left(4\right)& & c\left(4N+2\right)& c\left(4N+4\right)& & \cdots & c\left(4N\left(N-1\right)+2\right)& c\left(4N\left(N-1\right)+4\right)\\ & & & & & & & & \\ c\left(5\right)& c\left(7\right)& & c\left(4N+5\right)& c\left(4N+7\right)& & \cdots & c\left(4N\left(N-1\right)+5\right)& c\left(4N\left(N-1\right)+7\right)\\ c\left(6\right)& c\left(8\right)& & c\left(4N+6\right)& c\left(4N+8\right)& & \cdots & c\left(4N\left(N-1\right)+6\right)& c\left(4N\left(N-1\right)+8\right)\\ & & & & & & & & \\ ⋮& ⋮& & ⋮& ⋮& & \ddots & ⋮& ⋮\\ c\left(4N-3\right)& c\left(4N-1\right)& & c\left(8N-3\right)& c\left(8N-1\right)& & \cdots & c\left(4{N}^{2}-3\right)& c\left(4{N}^{2}-1\right)\\ c\left(4N-2\right)& c\left(4N\right)& & c\left(8N-2\right)& c\left(8N\right)& & \cdots & c\left(4{N}^{2}-2\right)& c\left(4{N}^{2}\right)\end{array}\right)$`

Coefficient c(i,j,k,l) is in row (4N(j–1) + 4i + 2l + k – 6) of the vector `c`.

For 3-D systems,

`$\left(\begin{array}{cccccccccccc}c\left(1\right)& c\left(4\right)& c\left(7\right)& & c\left(9N+1\right)& c\left(9N+4\right)& c\left(9N+7\right)& & \cdots & c\left(9N\left(N-1\right)+1\right)& c\left(9N\left(N-1\right)+4\right)& c\left(9N\left(N-1\right)+7\right)\\ c\left(2\right)& c\left(5\right)& c\left(8\right)& & c\left(9N+2\right)& c\left(9N+5\right)& c\left(9N+8\right)& & \cdots & c\left(9N\left(N-1\right)+2\right)& c\left(9N\left(N-1\right)+5\right)& c\left(9N\left(N-1\right)+8\right)\\ c\left(3\right)& c\left(6\right)& c\left(9\right)& & c\left(9N+3\right)& c\left(9N+6\right)& c\left(9N+9\right)& & \cdots & c\left(9N\left(N-1\right)+3\right)& c\left(9N\left(N-1\right)+6\right)& c\left(9N\left(N-1\right)+9\right)\\ & & & & & & & & & & & \\ c\left(10\right)& c\left(13\right)& c\left(16\right)& & c\left(9N+10\right)& c\left(9N+13\right)& c\left(9N+16\right)& & \cdots & c\left(9N\left(N-1\right)+10\right)& c\left(9N\left(N-1\right)+13\right)& c\left(9N\left(N-1\right)+16\right)\\ c\left(11\right)& c\left(14\right)& c\left(17\right)& & c\left(9N+11\right)& c\left(9N+14\right)& c\left(9N+17\right)& & \cdots & c\left(9N\left(N-1\right)+11\right)& c\left(9N\left(N-1\right)+14\right)& c\left(9N\left(N-1\right)+17\right)\\ c\left(12\right)& c\left(15\right)& c\left(18\right)& & c\left(9N+12\right)& c\left(9N+15\right)& c\left(9N+18\right)& & \cdots & c\left(9N\left(N-1\right)+12\right)& c\left(9N\left(N-1\right)+15\right)& c\left(9N\left(N-1\right)+18\right)\\ ⋮& ⋮& ⋮& & ⋮& ⋮& ⋮& & \ddots & ⋮& ⋮& ⋮\\ c\left(9N-8\right)& c\left(9N-5\right)& c\left(9N-2\right)& & c\left(18N-8\right)& c\left(18N-5\right)& c\left(18N-2\right)& & \cdots & c\left(9{N}^{2}-8\right)& c\left(9{N}^{2}-5\right)& c\left(9{N}^{2}-2\right)\\ c\left(9N-7\right)& c\left(9N-4\right)& c\left(9N-1\right)& & c\left(18N-7\right)& c\left(18N-4\right)& c\left(18N-1\right)& & \cdots & c\left(9{N}^{2}-7\right)& c\left(9{N}^{2}-4\right)& c\left(9{N}^{2}-1\right)\\ c\left(9N-6\right)& c\left(9N-3\right)& c\left(9N\right)& & c\left(18N-6\right)& c\left(18N-3\right)& c\left(18N\right)& & \cdots & c\left(9{N}^{2}-6\right)& c\left(9{N}^{2}-3\right)& c\left(9{N}^{2}\right)\end{array}\right)$`

Coefficient c(i,j,k,l) is in row (9N(j–1) + 9i + 3l + k – 12) of the vector `c`.

### Some c Vectors Can Be Short

Often, your tensor c has structure, such as symmetric or block diagonal. In many cases, you can represent c using a smaller vector than one with 4N2 components for 2-D or 9N2 components for 3-D. The following sections give the possibilities.

#### 2-D Systems

Scalar c, 2-D Systems.  The software interprets a scalar c as a diagonal matrix, with c(i,i,1,1) and c(i,i,2,2) equal to the scalar, and all other entries 0.

`$\left(\begin{array}{ccccccccc}c& 0& & 0& 0& & \cdots & 0& 0\\ 0& c& & 0& 0& & \cdots & 0& 0\\ & & & & & & & & \\ 0& 0& & c& 0& & \cdots & 0& 0\\ 0& 0& & 0& c& & \cdots & 0& 0\\ & & & & & & & & \\ ⋮& ⋮& & ⋮& ⋮& & \ddots & ⋮& ⋮\\ 0& 0& & 0& 0& & \cdots & c& 0\\ 0& 0& & 0& 0& & \cdots & 0& c\end{array}\right)$`

Two-Element Column Vector c, 2-D Systems.  The software interprets a two-element column vector c as a diagonal matrix, with c(i,i,1,1) and c(i,i,2,2) as the two entries, and all other entries 0.

`$\left(\begin{array}{ccccccccc}c\left(1\right)& 0& & 0& 0& & \cdots & 0& 0\\ 0& c\left(2\right)& & 0& 0& & \cdots & 0& 0\\ & & & & & & & & \\ 0& 0& & c\left(1\right)& 0& & \cdots & 0& 0\\ 0& 0& & 0& c\left(2\right)& & \cdots & 0& 0\\ & & & & & & & & \\ ⋮& ⋮& & ⋮& ⋮& & \ddots & ⋮& ⋮\\ 0& 0& & 0& 0& & \cdots & c\left(1\right)& 0\\ 0& 0& & 0& 0& & \cdots & 0& c\left(2\right)\end{array}\right)$`

Three-Element Column Vector c, 2-D Systems.  The software interprets a three-element column vector c as a symmetric block diagonal matrix, with c(i,i,1,1) = c(1), c(i,i,2,2) = c(3), and c(i,i,1,2) = c(i,i,2,1) = c(2).

`$\left(\begin{array}{ccccccccc}c\left(1\right)& c\left(2\right)& & 0& 0& & \cdots & 0& 0\\ c\left(2\right)& c\left(3\right)& & 0& 0& & \cdots & 0& 0\\ & & & & & & & & \\ 0& 0& & c\left(1\right)& c\left(2\right)& & \cdots & 0& 0\\ 0& 0& & c\left(2\right)& c\left(3\right)& & \cdots & 0& 0\\ & & & & & & & & \\ ⋮& ⋮& & ⋮& ⋮& & \ddots & ⋮& ⋮\\ 0& 0& & 0& 0& & \cdots & c\left(1\right)& c\left(2\right)\\ 0& 0& & 0& 0& & \cdots & c\left(2\right)& c\left(3\right)\end{array}\right)$`

Four-Element Column Vector c, 2-D Systems.  The software interprets a four-element column vector c as a block diagonal matrix.

`$\left(\begin{array}{ccccccccc}c\left(1\right)& c\left(3\right)& & 0& 0& & \cdots & 0& 0\\ c\left(2\right)& c\left(4\right)& & 0& 0& & \cdots & 0& 0\\ & & & & & & & & \\ 0& 0& & c\left(1\right)& c\left(3\right)& & \cdots & 0& 0\\ 0& 0& & c\left(2\right)& c\left(4\right)& & \cdots & 0& 0\\ & & & & & & & & \\ ⋮& ⋮& & ⋮& ⋮& & \ddots & ⋮& ⋮\\ 0& 0& & 0& 0& & \cdots & c\left(1\right)& c\left(3\right)\\ 0& 0& & 0& 0& & \cdots & c\left(2\right)& c\left(4\right)\end{array}\right)$`

N-Element Column Vector c, 2-D Systems.  The software interprets an N-element column vector c as a diagonal matrix.

`$\left(\begin{array}{ccccccccc}c\left(1\right)& 0& & 0& 0& & \cdots & 0& 0\\ 0& c\left(1\right)& & 0& 0& & \cdots & 0& 0\\ & & & & & & & & \\ 0& 0& & c\left(2\right)& 0& & \cdots & 0& 0\\ 0& 0& & 0& c\left(2\right)& & \cdots & 0& 0\\ & & & & & & & & \\ ⋮& ⋮& & ⋮& ⋮& & \ddots & ⋮& ⋮\\ 0& 0& & 0& 0& & \cdots & c\left(N\right)& 0\\ 0& 0& & 0& 0& & \cdots & 0& c\left(N\right)\end{array}\right)$`

Caution

If N = 2, 3, or 4, the 2-, 3-, or 4-element column vector form takes precedence over the N-element form. For example, if N = 3, and you have a c matrix of the form

`$\left(\begin{array}{cccccc}c1& 0& 0& 0& 0& 0\\ 0& c1& 0& 0& 0& 0\\ 0& 0& c2& 0& 0& 0\\ 0& 0& 0& c2& 0& 0\\ 0& 0& 0& 0& c3& 0\\ 0& 0& 0& 0& 0& c3\end{array}\right)$`

you cannot use the N-element form of c. Instead, you must use the 2N-element form. If you give c as the vector `[c1;c2;c3]`, the software interprets `c` as a 3-element form:

`$\left(\begin{array}{cccccc}c1& c2& 0& 0& 0& 0\\ c2& c3& 0& 0& 0& 0\\ 0& 0& c1& c2& 0& 0\\ 0& 0& c2& c3& 0& 0\\ 0& 0& 0& 0& c1& c2\\ 0& 0& 0& 0& c2& c3\end{array}\right)$`

Instead, use the 2N-element form `[c1;c1;c2;c2;c3;c3]`.

2N-Element Column Vector c, 2-D Systems.  The software interprets a 2N-element column vector c as a diagonal matrix.

`$\left(\begin{array}{ccccccccc}c\left(1\right)& 0& & 0& 0& & \cdots & 0& 0\\ 0& c\left(2\right)& & 0& 0& & \cdots & 0& 0\\ & & & & & & & & \\ 0& 0& & c\left(3\right)& 0& & \cdots & 0& 0\\ 0& 0& & 0& c\left(4\right)& & \cdots & 0& 0\\ & & & & & & & & \\ ⋮& ⋮& & ⋮& ⋮& & \ddots & ⋮& ⋮\\ 0& 0& & 0& 0& & \cdots & c\left(2N-1\right)& 0\\ 0& 0& & 0& 0& & \cdots & 0& c\left(2N\right)\end{array}\right)$`

Caution

If N = 2, the 4-element form takes precedence over the 2N-element form. For example, if your c matrix is

`$\left(\begin{array}{cccc}c1& 0& 0& 0\\ 0& c2& 0& 0\\ 0& 0& c3& 0\\ 0& 0& 0& c4\end{array}\right)$`

you cannot give c as `[c1;c2;c3;c4]`, because the software interprets this vector as the 4-element form

`$\left(\begin{array}{cccc}c1& c3& 0& 0\\ c2& c4& 0& 0\\ 0& 0& c1& c3\\ 0& 0& c2& c4\end{array}\right)$`

Instead, use the 3N-element form `[c1;0;c2;c3;0;c4]` or the 4N-element form `[c1;0;0;c2;c3;0;0;c4]`.

3N-Element Column Vector c, 2-D Systems.  The software interprets a 3N-element column vector c as a symmetric block diagonal matrix.

`$\left(\begin{array}{ccccccccc}c\left(1\right)& c\left(2\right)& & 0& 0& & \cdots & 0& 0\\ c\left(2\right)& c\left(3\right)& & 0& 0& & \cdots & 0& 0\\ & & & & & & & & \\ 0& 0& & c\left(4\right)& c\left(5\right)& & \cdots & 0& 0\\ 0& 0& & c\left(5\right)& c\left(6\right)& & \cdots & 0& 0\\ & & & & & & & & \\ ⋮& ⋮& & ⋮& ⋮& & \ddots & ⋮& ⋮\\ 0& 0& & 0& 0& & \cdots & c\left(3N-2\right)& c\left(3N-1\right)\\ 0& 0& & 0& 0& & \cdots & c\left(3N-1\right)& c\left(3N\right)\end{array}\right)$`

Coefficient c(i,j,k,l) is in row (3i + k + l – 4) of the vector `c`.

4N-Element Column Vector c, 2-D Systems.  The software interprets a 4N-element column vector c as a block diagonal matrix.

`$\left(\begin{array}{ccccccccc}c\left(1\right)& c\left(3\right)& & 0& 0& & \cdots & 0& 0\\ c\left(2\right)& c\left(4\right)& & 0& 0& & \cdots & 0& 0\\ & & & & & & & & \\ 0& 0& & c\left(5\right)& c\left(7\right)& & \cdots & 0& 0\\ 0& 0& & c\left(6\right)& c\left(8\right)& & \cdots & 0& 0\\ & & & & & & & & \\ ⋮& ⋮& & ⋮& ⋮& & \ddots & ⋮& ⋮\\ 0& 0& & 0& 0& & \cdots & c\left(4N-3\right)& c\left(4N-1\right)\\ 0& 0& & 0& 0& & \cdots & c\left(4N-2\right)& c\left(4N\right)\end{array}\right)$`

Coefficient c(i,j,k,l) is in row (4i + 2l + k – 6) of the vector `c`.

2N(2N+1)/2-Element Column Vector c, 2-D Systems.  The software interprets a 2N(2N+1)/2-element column vector c as a symmetric matrix. In the following diagram, • means the entry is symmetric.

`$\left(\begin{array}{ccccccccc}c\left(1\right)& c\left(2\right)& & c\left(4\right)& c\left(6\right)& & \cdots & c\left(\left(N-1\right)\left(2N-1\right)+1\right)& c\left(\left(N-1\right)\left(2N-1\right)+3\right)\\ •& c\left(3\right)& & c\left(5\right)& c\left(7\right)& & \cdots & c\left(\left(N-1\right)\left(2N-1\right)+2\right)& c\left(\left(N-1\right)\left(2N-1\right)+4\right)\\ & & & & & & & & \\ •& •& & c\left(8\right)& c\left(9\right)& & \cdots & c\left(\left(N-1\right)\left(2N-1\right)+5\right)& c\left(\left(N-1\right)\left(2N-1\right)+7\right)\\ •& •& & •& c\left(10\right)& & \cdots & c\left(\left(N-1\right)\left(2N-1\right)+6\right)& c\left(\left(N-1\right)\left(2N-1\right)+8\right)\\ & & & & & & & & \\ ⋮& ⋮& & ⋮& ⋮& & \ddots & ⋮& ⋮\\ •& •& & •& •& & \cdots & c\left(N\left(2N+1\right)-2\right)& c\left(N\left(2N+1\right)-1\right)\\ •& •& & •& •& & \cdots & •& c\left(N\left(2N+1\right)\right)\end{array}\right)$`

Coefficient c(i,j,k,l), for i < j, is in row (2j2 – 3j + 4i + 2l + k – 5) of the vector `c`. For i = j, coefficient c(i,j,k,l) is in row (2i2 + i + l + k – 4) of the vector `c`.

4N2-Element Column Vector c, 2-D Systems.  The software interprets a 4N2-element column vector c as a matrix.

`$\left(\begin{array}{ccccccccc}c\left(1\right)& c\left(3\right)& & c\left(4N+1\right)& c\left(4N+3\right)& & \cdots & c\left(4N\left(N-1\right)+1\right)& c\left(4N\left(N-1\right)+3\right)\\ c\left(2\right)& c\left(4\right)& & c\left(4N+2\right)& c\left(4N+4\right)& & \cdots & c\left(4N\left(N-1\right)+2\right)& c\left(4N\left(N-1\right)+4\right)\\ & & & & & & & & \\ c\left(5\right)& c\left(7\right)& & c\left(4N+5\right)& c\left(4N+7\right)& & \cdots & c\left(4N\left(N-1\right)+5\right)& c\left(4N\left(N-1\right)+7\right)\\ c\left(6\right)& c\left(8\right)& & c\left(4N+6\right)& c\left(4N+8\right)& & \cdots & c\left(4N\left(N-1\right)+6\right)& c\left(4N\left(N-1\right)+8\right)\\ & & & & & & & & \\ ⋮& ⋮& & ⋮& ⋮& & \ddots & ⋮& ⋮\\ c\left(4N-3\right)& c\left(4N-1\right)& & c\left(8N-3\right)& c\left(8N-1\right)& & \cdots & c\left(4{N}^{2}-3\right)& c\left(4{N}^{2}-1\right)\\ c\left(4N-2\right)& c\left(4N\right)& & c\left(8N-2\right)& c\left(8N\right)& & \cdots & c\left(4{N}^{2}-2\right)& c\left(4{N}^{2}\right)\end{array}\right)$`

Coefficient c(i,j,k,l) is in row (4N(j–1) + 4i + 2l + k – 6) of the vector `c`.

#### 3-D Systems

Scalar c, 3-D Systems.  The software interprets a scalar c as a diagonal matrix, with c(i,i,1,1), c(i,i,2,2), and c(i,i,3,3) equal to the scalar, and all other entries 0.

`$\left(\begin{array}{ccccccccccc}c& 0& 0& & 0& 0& 0& \cdots & 0& 0& 0\\ 0& c& 0& & 0& 0& 0& \cdots & 0& 0& 0\\ 0& 0& c& & 0& 0& 0& \cdots & 0& 0& 0\\ & & & & & & & & & & \\ 0& 0& 0& & c& 0& 0& \cdots & 0& 0& 0\\ 0& 0& 0& & 0& c& 0& \cdots & 0& 0& 0\\ 0& 0& 0& & 0& 0& c& \cdots & 0& 0& 0\\ ⋮& ⋮& ⋮& & ⋮& ⋮& ⋮& \ddots & ⋮& ⋮& ⋮\\ 0& 0& 0& & 0& 0& 0& \cdots & c& 0& 0\\ 0& 0& 0& & 0& 0& 0& \cdots & 0& c& 0\\ 0& 0& 0& & 0& 0& 0& \cdots & 0& 0& c\end{array}\right)$`

Three-Element Column Vector c, 3-D Systems.  The software interprets a three-element column vector c as a diagonal matrix, with c(i,i,1,1), c(i,i,2,2), and c(i,i,3,3) as the three entries, and all other entries 0.

`$\left(\begin{array}{ccccccccccc}c\left(1\right)& 0& 0& & 0& 0& 0& \cdots & 0& 0& 0\\ 0& c\left(2\right)& 0& & 0& 0& 0& \cdots & 0& 0& 0\\ 0& 0& c\left(3\right)& & 0& 0& 0& \cdots & 0& 0& 0\\ & & & & & & & & & & \\ 0& 0& 0& & c\left(1\right)& 0& 0& \cdots & 0& 0& 0\\ 0& 0& 0& & 0& c\left(2\right)& 0& \cdots & 0& 0& 0\\ 0& 0& 0& & 0& 0& c\left(3\right)& \cdots & 0& 0& 0\\ ⋮& ⋮& ⋮& & ⋮& ⋮& ⋮& \ddots & ⋮& ⋮& ⋮\\ 0& 0& 0& & 0& 0& 0& \cdots & c\left(1\right)& 0& 0\\ 0& 0& 0& & 0& 0& 0& \cdots & 0& c\left(2\right)& 0\\ 0& 0& 0& & 0& 0& 0& \cdots & 0& 0& c\left(3\right)\end{array}\right)$`

Six-Element Column Vector c, 3-D Systems.  The software interprets a six-element column vector c as a symmetric block diagonal matrix, with

c(i,i,1,1) = c(1)
c(i,i,2,2) = c(3)
c(i,i,1,2) = c(i,i,2,1) = c(2)
c(i,i,1,3) = c(i,i,3,1) = c(4)
c(i,i,2,3) = c(i,i,3,2) = c(5)
c(i,i,3,3) = c(6).

In the following diagram, • means the entry is symmetric.

`$\left(\begin{array}{ccccccccccc}c\left(1\right)& c\left(2\right)& c\left(4\right)& & 0& 0& 0& \cdots & 0& 0& 0\\ •& c\left(3\right)& c\left(5\right)& & 0& 0& 0& \cdots & 0& 0& 0\\ •& •& c\left(6\right)& & 0& 0& 0& \cdots & 0& 0& 0\\ & & & & & & & & & & \\ 0& 0& 0& & c\left(1\right)& c\left(2\right)& c\left(4\right)& \cdots & 0& 0& 0\\ 0& 0& 0& & •& c\left(3\right)& c\left(5\right)& \cdots & 0& 0& 0\\ 0& 0& 0& & •& •& c\left(6\right)& \cdots & 0& 0& 0\\ ⋮& ⋮& ⋮& & ⋮& ⋮& ⋮& \ddots & ⋮& ⋮& ⋮\\ 0& 0& 0& & 0& 0& 0& \cdots & c\left(1\right)& c\left(2\right)& c\left(4\right)\\ 0& 0& 0& & 0& 0& 0& \cdots & •& c\left(3\right)& c\left(5\right)\\ 0& 0& 0& & 0& 0& 0& \cdots & •& •& c\left(6\right)\end{array}\right)$`

Nine-Element Column Vector c, 3-D Systems.  The software interprets a nine-element column vector c as a block diagonal matrix.

`$\left(\begin{array}{ccccccccccc}c\left(1\right)& c\left(4\right)& c\left(7\right)& & 0& 0& 0& \cdots & 0& 0& 0\\ c\left(2\right)& c\left(5\right)& c\left(8\right)& & 0& 0& 0& \cdots & 0& 0& 0\\ c\left(3\right)& c\left(6\right)& c\left(9\right)& & 0& 0& 0& \cdots & 0& 0& 0\\ & & & & & & & & & & \\ 0& 0& 0& & c\left(1\right)& c\left(4\right)& c\left(7\right)& \cdots & 0& 0& 0\\ 0& 0& 0& & c\left(2\right)& c\left(5\right)& c\left(8\right)& \cdots & 0& 0& 0\\ 0& 0& 0& & c\left(3\right)& c\left(6\right)& c\left(9\right)& \cdots & 0& 0& 0\\ ⋮& ⋮& ⋮& & ⋮& ⋮& ⋮& \ddots & ⋮& ⋮& ⋮\\ 0& 0& 0& & 0& 0& 0& \cdots & c\left(1\right)& c\left(4\right)& c\left(7\right)\\ 0& 0& 0& & 0& 0& 0& \cdots & c\left(2\right)& c\left(5\right)& c\left(8\right)\\ 0& 0& 0& & 0& 0& 0& \cdots & c\left(3\right)& c\left(6\right)& c\left(3\right)\end{array}\right)$`

N-Element Column Vector c, 3-D Systems.  The software interprets an N-element column vector c as a diagonal matrix.

`$\left(\begin{array}{ccccccccccc}c\left(1\right)& 0& 0& & 0& 0& 0& \cdots & 0& 0& 0\\ 0& c\left(1\right)& 0& & 0& 0& 0& \cdots & 0& 0& 0\\ 0& 0& c\left(1\right)& & 0& 0& 0& \cdots & 0& 0& 0\\ & & & & & & & & & & \\ 0& 0& 0& & c\left(2\right)& 0& 0& \cdots & 0& 0& 0\\ 0& 0& 0& & 0& c\left(2\right)& 0& \cdots & 0& 0& 0\\ 0& 0& 0& & 0& 0& c\left(2\right)& \cdots & 0& 0& 0\\ ⋮& ⋮& ⋮& & ⋮& ⋮& ⋮& \ddots & ⋮& ⋮& ⋮\\ 0& 0& 0& & 0& 0& 0& \cdots & c\left(N\right)& 0& 0\\ 0& 0& 0& & 0& 0& 0& \cdots & 0& c\left(N\right)& 0\\ 0& 0& 0& & 0& 0& 0& \cdots & 0& 0& c\left(N\right)\end{array}\right)$`

Caution

If N = 3, 6, or 9, the 3-, 6-, or 9-element column vector form takes precedence over the N-element form. For example, if N = 3, and you have a c matrix of the form

`$\left(\begin{array}{ccccccccccc}c\left(1\right)& 0& 0& & 0& 0& 0& & 0& 0& 0\\ 0& c\left(1\right)& 0& & 0& 0& 0& & 0& 0& 0\\ 0& 0& c\left(1\right)& & 0& 0& 0& & 0& 0& 0\\ & & & & & & & & & & \\ 0& 0& 0& & c\left(2\right)& 0& 0& & 0& 0& 0\\ 0& 0& 0& & 0& c\left(2\right)& 0& & 0& 0& 0\\ 0& 0& 0& & 0& 0& c\left(2\right)& & 0& 0& 0\\ & & & & & & & & & & \\ 0& 0& 0& & 0& 0& 0& & c\left(3\right)& 0& 0\\ 0& 0& 0& & 0& 0& 0& & 0& c\left(3\right)& 0\\ 0& 0& 0& & 0& 0& 0& & 0& 0& c\left(3\right)\end{array}\right)$`

you cannot use the N-element form of c. If you give c as the vector `[c1;c2;c3]`, the software interprets `c` as a 3-element form:

`$\left(\begin{array}{ccccccccccc}c\left(1\right)& 0& 0& & 0& 0& 0& & 0& 0& 0\\ 0& c\left(2\right)& 0& & 0& 0& 0& & 0& 0& 0\\ 0& 0& c\left(3\right)& & 0& 0& 0& & 0& 0& 0\\ & & & & & & & & & & \\ 0& 0& 0& & c\left(1\right)& 0& 0& & 0& 0& 0\\ 0& 0& 0& & 0& c\left(2\right)& 0& & 0& 0& 0\\ 0& 0& 0& & 0& 0& c\left(3\right)& & 0& 0& 0\\ & & & & & & & & & & \\ 0& 0& 0& & 0& 0& 0& & c\left(1\right)& 0& 0\\ 0& 0& 0& & 0& 0& 0& & 0& c\left(2\right)& 0\\ 0& 0& 0& & 0& 0& 0& & 0& 0& c\left(3\right)\end{array}\right)$`

Instead, use one of these forms:

• 6N-element form — `[c1;0;c1;0;0;c1;c2;0;c2;0;0;c2;c3;0;c3;0;0;c3]`

• 9N-element form — `[c1;0;0;0;c1;0;0;0;c1;c2;0;0;0;c2;0;0;0;c2;c3;0;0;0;c3;0;0;0;c3]`

3N-Element Column Vector c, 3-D Systems.  The software interprets a 3N-element column vector c as a diagonal matrix.

`$\left(\begin{array}{ccccccccccc}c\left(1\right)& 0& 0& & 0& 0& 0& \cdots & 0& 0& 0\\ 0& c\left(2\right)& 0& & 0& 0& 0& \cdots & 0& 0& 0\\ 0& 0& c\left(3\right)& & 0& 0& 0& \cdots & 0& 0& 0\\ & & & & & & & & & & \\ 0& 0& 0& & c\left(4\right)& 0& 0& \cdots & 0& 0& 0\\ 0& 0& 0& & 0& c\left(5\right)& 0& \cdots & 0& 0& 0\\ 0& 0& 0& & 0& 0& c\left(6\right)& \cdots & 0& 0& 0\\ ⋮& ⋮& ⋮& & ⋮& ⋮& ⋮& \ddots & ⋮& ⋮& ⋮\\ 0& 0& 0& & 0& 0& 0& \cdots & c\left(3N-2\right)& 0& 0\\ 0& 0& 0& & 0& 0& 0& \cdots & 0& c\left(3N-1\right)& 0\\ 0& 0& 0& & 0& 0& 0& \cdots & 0& 0& c\left(3N\right)\end{array}\right)$`

Caution

If N = 3, the 9-element form takes precedence over the 3N-element form. For example, if your c matrix is

`$\left(\begin{array}{ccccccccccc}c\left(1\right)& 0& 0& & 0& 0& 0& & 0& 0& 0\\ 0& c\left(2\right)& 0& & 0& 0& 0& & 0& 0& 0\\ 0& 0& c\left(3\right)& & 0& 0& 0& & 0& 0& 0\\ & & & & & & & & & & \\ 0& 0& 0& & c\left(4\right)& 0& 0& & 0& 0& 0\\ 0& 0& 0& & 0& c\left(5\right)& 0& & 0& 0& 0\\ 0& 0& 0& & 0& 0& c\left(6\right)& & 0& 0& 0\\ & & & & & & & & & & \\ 0& 0& 0& & 0& 0& 0& & c\left(7\right)& 0& 0\\ 0& 0& 0& & 0& 0& 0& & 0& c\left(8\right)& 0\\ 0& 0& 0& & 0& 0& 0& & 0& 0& c\left(9\right)\end{array}\right)$`

you cannot give c as `[c1;c2;c3;c4;c5;c6;c7;c8;c9]`, because the software interprets this vector as the 9-element form

`$\left(\begin{array}{ccccccccccc}c\left(1\right)& c\left(4\right)& c\left(7\right)& & 0& 0& 0& & 0& 0& 0\\ c\left(2\right)& c\left(5\right)& c\left(8\right)& & 0& 0& 0& & 0& 0& 0\\ c\left(3\right)& c\left(6\right)& c\left(9\right)& & 0& 0& 0& & 0& 0& 0\\ & & & & & & & & & & \\ 0& 0& 0& & c\left(1\right)& c\left(4\right)& c\left(7\right)& & 0& 0& 0\\ 0& 0& 0& & c\left(2\right)& c\left(5\right)& c\left(8\right)& & 0& 0& 0\\ 0& 0& 0& & c\left(3\right)& c\left(6\right)& c\left(9\right)& & 0& 0& 0\\ & & & & & & & & & & \\ 0& 0& 0& & 0& 0& 0& & c\left(1\right)& c\left(4\right)& c\left(7\right)\\ 0& 0& 0& & 0& 0& 0& & c\left(2\right)& c\left(5\right)& c\left(8\right)\\ 0& 0& 0& & 0& 0& 0& & c\left(3\right)& c\left(6\right)& c\left(3\right)\end{array}\right)$`

Instead, use one of these forms:

• 6N-element form — `[c1;0;c2;0;0;c3;c4;0;c5;0;0;c6;c7;0;c8;0;0;c9]`

• 9N-element form — `[c1;0;0;0;c2;0;0;0;c3;c4;0;0;0;c5;0;0;0;c6;c7;0;0;0;c8;0;0;0;c9]`

6N-Element Column Vector c, 3-D Systems.  The software interprets a 6N-element column vector c as a symmetric block diagonal matrix. In the following diagram, • means the entry is symmetric.

`$\left(\begin{array}{ccccccccccc}c\left(1\right)& c\left(2\right)& c\left(4\right)& & 0& 0& 0& \cdots & 0& 0& 0\\ •& c\left(3\right)& c\left(5\right)& & 0& 0& 0& \cdots & 0& 0& 0\\ •& •& c\left(6\right)& & 0& 0& 0& \cdots & 0& 0& 0\\ & & & & & & & & & & \\ 0& 0& 0& & c\left(7\right)& c\left(8\right)& c\left(10\right)& \cdots & 0& 0& 0\\ 0& 0& 0& & •& c\left(9\right)& c\left(11\right)& \cdots & 0& 0& 0\\ 0& 0& 0& & •& •& c\left(12\right)& \cdots & 0& 0& 0\\ ⋮& ⋮& ⋮& & ⋮& ⋮& ⋮& \ddots & ⋮& ⋮& ⋮\\ 0& 0& 0& & 0& 0& 0& \cdots & c\left(6N-5\right)& c\left(6N-4\right)& c\left(6N-2\right)\\ 0& 0& 0& & 0& 0& 0& \cdots & •& c\left(6N-3\right)& c\left(6N-1\right)\\ 0& 0& 0& & 0& 0& 0& \cdots & •& •& c\left(6N\right)\end{array}\right)$`

Coefficient c(i,j,k,l) is in row (6i + k + 1/2l(l–1) – 6) of the vector `c`.

9N-Element Column Vector c, 3-D Systems.  The software interprets a 9N-element column vector c as a block diagonal matrix.

`$\left(\begin{array}{ccccccccccc}c\left(1\right)& c\left(4\right)& c\left(7\right)& & 0& 0& 0& \cdots & 0& 0& 0\\ c\left(2\right)& c\left(5\right)& c\left(8\right)& & 0& 0& 0& \cdots & 0& 0& 0\\ c\left(3\right)& c\left(6\right)& c\left(9\right)& & 0& 0& 0& \cdots & 0& 0& 0\\ & & & & & & & & & & \\ 0& 0& 0& & c\left(10\right)& c\left(13\right)& c\left(16\right)& \cdots & 0& 0& 0\\ 0& 0& 0& & c\left(11\right)& c\left(14\right)& c\left(17\right)& \cdots & 0& 0& 0\\ 0& 0& 0& & c\left(12\right)& c\left(15\right)& c\left(18\right)& \cdots & 0& 0& 0\\ ⋮& ⋮& ⋮& & ⋮& ⋮& ⋮& \ddots & ⋮& ⋮& ⋮\\ 0& 0& 0& & 0& 0& 0& \cdots & c\left(9N-8\right)& c\left(9N-5\right)& c\left(9N-2\right)\\ 0& 0& 0& & 0& 0& 0& \cdots & c\left(9N-7\right)& c\left(9N-4\right)& c\left(9N-1\right)\\ 0& 0& 0& & 0& 0& 0& \cdots & c\left(9N-6\right)& c\left(9N-3\right)& c\left(9N\right)\end{array}\right)$`

Coefficient c(i,j,k,l) is in row (9i + 3l + k – 12) of the vector `c`.

3N(3N+1)/2-Element Column Vector c, 3-D Systems.  The software interprets a 3N(3N+1)/2-element column vector c as a symmetric matrix. In the following diagram, • means the entry is symmetric.

`$\left(\begin{array}{ccccccccccc}c\left(1\right)& c\left(2\right)& c\left(4\right)& & c\left(7\right)& c\left(10\right)& c\left(13\right)& \cdots & c\left(3\left(N-1\right)\left(3\left(N-1\right)+1\right)/2+1& c\left(3\left(N-1\right)\left(3\left(N-1\right)+1\right)/2+4& c\left(3\left(N-1\right)\left(3\left(N-1\right)+1\right)/2+7\\ •& c\left(3\right)& c\left(5\right)& & c\left(8\right)& c\left(11\right)& c\left(14\right)& \cdots & c\left(3\left(N-1\right)\left(3\left(N-1\right)+1\right)/2+2& c\left(3\left(N-1\right)\left(3\left(N-1\right)+1\right)/2+5& c\left(3\left(N-1\right)\left(3\left(N-1\right)+1\right)/2+8\\ •& •& c\left(6\right)& & c\left(9\right)& c\left(12\right)& c\left(15\right)& \cdots & c\left(3\left(N-1\right)\left(3\left(N-1\right)+1\right)/2+3& c\left(3\left(N-1\right)\left(3\left(N-1\right)+1\right)/2+6& c\left(3\left(N-1\right)\left(3\left(N-1\right)+1\right)/2+9\\ & & & & & & & & & & \\ •& •& •& & c\left(16\right)& c\left(17\right)& c\left(19\right)& \cdots & c\left(3\left(N-1\right)\left(3\left(N-1\right)+1\right)/2+10& c\left(3\left(N-1\right)\left(3\left(N-1\right)+1\right)/2+13& c\left(3\left(N-1\right)\left(3\left(N-1\right)+1\right)/2+16\\ •& •& •& & •& c\left(18\right)& c\left(20\right)& \cdots & c\left(3\left(N-1\right)\left(3\left(N-1\right)+1\right)/2+11& c\left(3\left(N-1\right)\left(3\left(N-1\right)+1\right)/2+14& c\left(3\left(N-1\right)\left(3\left(N-1\right)+1\right)/2+17\\ •& •& •& & •& •& c\left(21\right)& \cdots & c\left(3\left(N-1\right)\left(3\left(N-1\right)+1\right)/2+12& c\left(3\left(N-1\right)\left(3\left(N-1\right)+1\right)/2+15& c\left(3\left(N-1\right)\left(3\left(N-1\right)+1\right)/2+18\\ ⋮& ⋮& ⋮& & ⋮& ⋮& ⋮& \ddots & ⋮& ⋮& ⋮\\ •& •& •& & •& •& •& \cdots & c\left(3N\left(3N+1\right)/2-5\right)& c\left(3N\left(3N+1\right)/2-4\right)& c\left(3N\left(3N+1\right)/2-2\right)\\ •& •& •& & •& •& •& \cdots & •& c\left(3N\left(3N+1\right)/2-3\right)& c\left(3N\left(3N+1\right)/2-1\right)\\ •& •& •& & •& •& •& \cdots & •& •& c\left(3N\left(3N+1\right)/2\right)\end{array}\right)$`

Coefficient c(i,j,k,l), for i < j, is in row (9(j–1)(j–2)/2 + 6(j–1) + 9i + 3l + k – 12) of the vector `c`. For i = j, coefficient c(i,j,k,l) is in row (9(i–1)(i–2)/2 + 15(i–1) + 1/2l(l–1) + k) of the vector `c`.

9N2-Element Column Vector c, 3-D Systems.  The software interprets a 9N2-element column vector c as a matrix.

`$\left(\begin{array}{cccccccccccc}c\left(1\right)& c\left(4\right)& c\left(7\right)& & c\left(9N+1\right)& c\left(9N+4\right)& c\left(9N+7\right)& & \cdots & c\left(9N\left(N-1\right)+1\right)& c\left(9N\left(N-1\right)+4\right)& c\left(9N\left(N-1\right)+7\right)\\ c\left(2\right)& c\left(5\right)& c\left(8\right)& & c\left(9N+2\right)& c\left(9N+5\right)& c\left(9N+8\right)& & \cdots & c\left(9N\left(N-1\right)+2\right)& c\left(9N\left(N-1\right)+5\right)& c\left(9N\left(N-1\right)+8\right)\\ c\left(3\right)& c\left(6\right)& c\left(9\right)& & c\left(9N+3\right)& c\left(9N+6\right)& c\left(9N+9\right)& & \cdots & c\left(9N\left(N-1\right)+3\right)& c\left(9N\left(N-1\right)+6\right)& c\left(9N\left(N-1\right)+9\right)\\ & & & & & & & & & & & \\ c\left(10\right)& c\left(13\right)& c\left(16\right)& & c\left(9N+10\right)& c\left(9N+13\right)& c\left(9N+16\right)& & \cdots & c\left(9N\left(N-1\right)+10\right)& c\left(9N\left(N-1\right)+13\right)& c\left(9N\left(N-1\right)+16\right)\\ c\left(11\right)& c\left(14\right)& c\left(17\right)& & c\left(9N+11\right)& c\left(9N+14\right)& c\left(9N+17\right)& & \cdots & c\left(9N\left(N-1\right)+11\right)& c\left(9N\left(N-1\right)+14\right)& c\left(9N\left(N-1\right)+17\right)\\ c\left(12\right)& c\left(15\right)& c\left(18\right)& & c\left(9N+12\right)& c\left(9N+15\right)& c\left(9N+18\right)& & \cdots & c\left(9N\left(N-1\right)+12\right)& c\left(9N\left(N-1\right)+15\right)& c\left(9N\left(N-1\right)+18\right)\\ ⋮& ⋮& ⋮& & ⋮& ⋮& ⋮& & \ddots & ⋮& ⋮& ⋮\\ c\left(9N-8\right)& c\left(9N-5\right)& c\left(9N-2\right)& & c\left(18N-8\right)& c\left(18N-5\right)& c\left(18N-2\right)& & \cdots & c\left(9{N}^{2}-8\right)& c\left(9{N}^{2}-5\right)& c\left(9{N}^{2}-2\right)\\ c\left(9N-7\right)& c\left(9N-4\right)& c\left(9N-1\right)& & c\left(18N-7\right)& c\left(18N-4\right)& c\left(18N-1\right)& & \cdots & c\left(9{N}^{2}-7\right)& c\left(9{N}^{2}-4\right)& c\left(9{N}^{2}-1\right)\\ c\left(9N-6\right)& c\left(9N-3\right)& c\left(9N\right)& & c\left(18N-6\right)& c\left(18N-3\right)& c\left(18N\right)& & \cdots & c\left(9{N}^{2}-6\right)& c\left(9{N}^{2}-3\right)& c\left(9{N}^{2}\right)\end{array}\right)$`

Coefficient c(i,j,k,l) is in row (9N(j–1) + 9i + 3l + k – 12) of the vector `c`.

### Functional Form

If your `c` coefficient is not constant, represent it as a function of the form

`ccoeffunction(location,state)`

`solvepde` or `solvepdeeig` pass the `location` and `state` structures to `ccoeffunction`. The function must return a matrix of size N1-by-Nr, where:

• N1 is the number of coefficients you pass to the solver. There are several possible values of N1, detailed in Some c Vectors Can Be Short. For 2-D geometry, 1 ≤ N1 ≤ 4N2, and for 3-D geometry, 1 ≤ N1 ≤ 9N2.

• Nr is the number of points in the location that the solver passes. Nr is equal to the length of the `location.x` or any other `location` field. The function should evaluate `c` at these points.

Pass the coefficient to `specifyCoefficients` as a function handle, such as

`specifyCoefficients(model,'c',@ccoeffunction,...)`
• `location` is a structure with these fields:

• `location.x`

• `location.y`

• `location.z`

• `location.subdomain`

The fields `x`, `y`, and `z` represent the x-, y-, and z- coordinates of points for which your function calculates coefficient values. The `subdomain` field represents the subdomain numbers, which currently apply only to 2-D models. The location fields are row vectors.

• `state` is a structure with these fields:

• `state.u`

• `state.ux`

• `state.uy`

• `state.uz`

• `state.time`

The `state.u` field represents the current value of the solution u. The `state.ux`, `state.uy`, and `state.uz` fields are estimates of the solution’s partial derivatives (∂u/∂x, ∂u/∂y, and ∂u/∂z) at the corresponding points of the location structure. The solution and gradient estimates are N-by-Nr matrices. The `state.time` field is a scalar representing time for time-dependent models.

For example, suppose N = 3, and you have 2-D geometry. Suppose your `c` matrix is of the form

`$c=\left[\begin{array}{cccccccc}1& 2& & & & & & \\ 2& 8& & & & & & \\ & & & & & & & \\ & & & 1+{x}^{2}+{y}^{2}& \frac{u\left(2\right)}{1+u{\left(1\right)}^{2}+u{\left(3\right)}^{2}}& & & \\ & & & \frac{u\left(2\right)}{1+u{\left(1\right)}^{2}+u{\left(3\right)}^{2}}& 1+{x}^{2}+{y}^{2}& & & \\ & & & & & & & \\ & & & & & & {s}_{1}\left(x,y\right)& -1\\ & & & & & & -1& {s}_{1}\left(x,y\right)\end{array}\right]$`

where unlisted elements are zero. Here s1(x,y) is 5 in subdomain 1, and is 10 in subdomain 2.

This `c` is a symmetric, block-diagonal matrix with different coefficients in each block. So it is natural to represent `c` as a 3N-Element Column Vector c, 2-D Systems:

`$\left(\begin{array}{ccccccccc}c\left(1\right)& c\left(2\right)& & 0& 0& & \cdots & 0& 0\\ c\left(2\right)& c\left(3\right)& & 0& 0& & \cdots & 0& 0\\ & & & & & & & & \\ 0& 0& & c\left(4\right)& c\left(5\right)& & \cdots & 0& 0\\ 0& 0& & c\left(5\right)& c\left(6\right)& & \cdots & 0& 0\\ & & & & & & & & \\ ⋮& ⋮& & ⋮& ⋮& & \ddots & ⋮& ⋮\\ 0& 0& & 0& 0& & \cdots & c\left(3N-2\right)& c\left(3N-1\right)\\ 0& 0& & 0& 0& & \cdots & c\left(3N-1\right)& c\left(3N\right)\end{array}\right)$`

For that form, the following function is appropriate.

```function cmatrix = ccoeffunction(location,state) n1 = 9; nr = numel(location.x); cmatrix = zeros(n1,nr); cmatrix(1,:) = ones(1,nr); cmatrix(2,:) = 2*ones(1,nr); cmatrix(3,:) = 8*ones(1,nr); cmatrix(4,:) = 1+location.x.^2 + location.y.^2; cmatrix(5,:) = state.u(2,:)./(1 + state.u(1,:).^2 + state.u(3,:).^2); cmatrix(6,:) = cmatrix(4,:); cmatrix(7,:) = 5*location.subdomain; cmatrix(8,:) = -ones(1,nr); cmatrix(9,:) = cmatrix(7,:);```

To include this function as your `c` coefficient, pass the function handle `@ccoeffunction`:

`specifyCoefficients(model,'c',@ccoeffunction,...`

Get trial now