Mu Analysis and Synthesis Toolbox | ![]() ![]() |
Add and subtract CONSTANT, SYSTEM, and VARYING matrices
Syntax
out = madd(mat1,mat2,,matN) out = msub(mat1,mat2,,matN)
Description
madd
(msub
) allows the addition or subtraction of matrices, regardless of their type, as long as their dimensions are compatible. CONSTANT, SYSTEM, and VARYING matrices can be added to or subtracted from one another based on the following table:
|
mat2 |
CONSTANT |
SYSTEM |
VARYING |
|
||||
CONSTANT |
yes |
yes |
yes |
|
SYSTEM |
yes |
yes |
no |
|
VARYING |
yes |
no |
yes |
mat1
must equal the number of rows and columns of mat2
. In the case of SYSTEM matrices, the number of inputs and outputs of mat1
must equal the number of inputs and outputs of mat2
. The same is true for VARYING matrices and in addition, the independent variables of the VARYING matrices must be identical. Up to nine matrices of compatible dimension can be added or subtracted by including them as input arguments.
Pictorial Representationof Functions
Examples
Create two SYSTEM matrices p
and p1
and a CONSTANT matrix.
a = -10;b = 3;c = 10;d = 0; p =Adding two SYSTEM matrices returns a SYSTEM matrix with the same number of inputs and outputs aspck
(a,b,c,d);minfo
(p) system: 1 states 1 outputs1 inputs a1 = -2; b1 = 3; c1 = 1; d1 = .1;p1
=pck
(a1,b1,c1,d1);minfo
(p1
)seesys
(p,'3.2g') -10 | 3 -----|---- 10 | 0seesys
(p1
,'3.2g') -2 | 3 ----|---- 1 | .1
p
and p1
.
Adding a SYSTEM matrix and a CONSTANT matrix returns a SYSTEM matrix with the CONSTANT term added to the D-term of the state-space system.out
=madd
(p,p1
);seesys
(out
,'3.2g') -10 0 | 3 0 -2 | 3 ---------|------ 10 1 | .1minfo
(out
) system: 2 states1 outputs1 inputs
Subtracting a SYSTEM matrix and a CONSTANT returns a SYSTEM matrix with the CONSTANT term added to the D-term of the state-space system.out
=madd
(p,a);seesys
(out
,'%3.2g') -10 | 3 ------|----- 10 | -10
out
=msub
(p,a);seesys
(out
,'%3.2g') -10 | 3 ------|----- 10 | -10
Algorithm
madd
and msub
call the MATLAB + and - commands consistent with the type of matrices.
![]() | indvcmp | massign | ![]() |