(phi,gamma) = Matrices.integralExp(A,B); (phi,gamma) = Matrices.integralExp(A,B,T=1);
This function computes the exponential phi = e^(AT) of matrix A and the integral gamma = integral(phi*dt)*B.
The function uses a Taylor series expansion with Balancing and scaling/squaring to approximate the integral Ψ of the matrix exponential Φ=e^(AT):
AT^2 A^2 * T^3 A^k * T^(k+1) Ψ = int(e^(As))ds = IT + ---- + --------- + ... + -------------- 2! 3! (k+1)!
Φ is calculated through Φ = I + A*Ψ, so A may be singular. Γ is simply Ψ*B.
The algorithm runs in the following steps:
Balancing put the bad condition of a square matrix A
into a diagonal transformation matrix D. This reduce the
effort of following calculations. Afterwards the result have to be
re-balanced by transformation D*Atransf
*inv(D).
Scaling halfen T k-times, until the norm of A*T is less than
0.5. This guarantees minimum rounding errors in the following
series expansion. The re-scaling based on the equation
exp(A*2T) = exp(AT)^2. The needed re-scaling formula for psi thus
becomes:
Φ = Φ'*Φ' I + A*Ψ = I + 2A*Ψ' + A^2*Ψ'^2 Ψ = A*Ψ'^2 + 2*Ψ'
where psi' is the scaled result from the series expansion while psi is the re-scaled matrix.
The function is normally used to discretize a state-space system as the zero-order-hold equivalent:
x(k+1) = Φ*x(k) + Γ*u(k) y(k) = C*x(k) + D*u(k)
The zero-order-hold sampling, also known as step-invariant method, gives exact values of the state variables, under the assumption that the control signal u is constant between the sampling instants. Zero-order-hold sampling is described in
Syntax: (phi,gamma) = Matrices.expIntegral(A,B,T) A,phi: [n,n] square matrices B,gamma: [n,m] input matrix T: scalar, e.g., sampling time
The Algorithm to calculate psi is taken from
function integralExp extends Modelica.Icons.Function; input Real A[:, size(A, 1)]; input Real B[size(A, 1), :]; input Real T = 1; output Real phi[size(A, 1), size(A, 1)] "= exp(A*T)"; output Real gamma[size(A, 1), size(B, 2)] "= integral(phi)*B"; end integralExp;
Release Notes: