Documentation

incidenceMatrix

Find incidence matrix of system of equations

Description

example

A = incidenceMatrix(eqs,vars) for m equations eqs and n variables vars returns an m-by-n matrix A. Here, A(i,j) = 1 if eqs(i) contains vars(j) or any derivative of vars(j). All other elements of A are 0s.

Examples

Incidence Matrix

Find the incidence matrix of a system of five equations in five variables.

Create the following symbolic vector eqs containing five symbolic differential equations.

syms y1(t) y2(t) y3(t) y4(t) y5(t) c1 c3
eqs = [diff(y1(t),t) == y2(t),...
diff(y2(t),t) == c1*y1(t) + c3*y3(t),...
diff(y3(t),t) == y2(t) + y4(t),...
diff(y4(t),t) == y3(t) + y5(t),...
diff(y5(t),t) == y4(t)];

Create the vector of variables. Here, c1 and c3 are symbolic parameters (not variables) of the system.

vars = [y1(t), y2(t), y3(t), y4(t), y5(t)];

Find the incidence matrix A for the equations eqs and with respect to the variables vars.

A = incidenceMatrix(eqs, vars)
A =
1     1     0     0     0
1     1     1     0     0
0     1     1     1     0
0     0     1     1     1
0     0     0     1     1

Input Arguments

collapse all

Equations, specified as a vector of symbolic equations or expressions.

Variables, specified as a vector of symbolic variables, symbolic functions, or function calls, such as x(t).

Output Arguments

collapse all

Incidence matrix, returned as a matrix of double-precision values.