Switch language to: 中文
Project Structure (major part)
│ .gitignore
│ LICENSE
│ README.md
├─sources
│ └─Readme_zh.md
├─doc
│ └─doc.md
└─src
├─cpp
└─matlab
├─myPlace.m
├─myOrderedPlace.m
├─myRandomPlace.m
├─myAdvancedRandomPlace.m
└─test_samples.mlx
A second project of SDM364, Multi-variable Control and Applications, using matlab while basing on cpp to enhance the function place(A,B,poles)
in matlab.
Before applying this repo, make sure that you're able to access:
c++ version: standard 11
matlab: R2022a(or replacement)
Based on Bass-Gura Formula.
Pass.
The system is decomposed into controllable and uncontrollable parts. For example:
$$
A=\begin{bmatrix}
A_{11}~A_{12}\~0~~~A_{22}
\end{bmatrix}\
B=\begin{bmatrix}
B_{11}\0
\end{bmatrix}
$$
In this case, we need to find the transformation matrix
When we decompose the controllability matrix, we know that,
Calculate
How to find a column like this? Obviously, the left null space reflects the linear dependence of the columns of the matrix, so we can find the left null space of
function [T, A_c, B_c, A_uc, B_uc] = controllabilityDecomposition(A, B)
% Calculate the controllability matrix
C = ctrb(A, B);
% Determine the rank of the controllability matrix
rankC = rank(C);
% Select rankC independent columns from C
[U, S, V] = svd(C, 'econ');
independent_cols = V(:, 1:rankC);
% Ensure we have a full set of basis vectors for the state space
% If system is not fully controllable, complete the basis.
if rankC < size(A,1)
% Add additional vectors to span the entire space
% Find the null space of the controllability matrix
null_vectors = null(C');
% Construct T by combining the independent columns and the null space
T = [independent_cols, null_vectors];
else
% System is fully controllable
T = independent_cols;
end
% Verify that T is full rank (mostly it is full rank)
if rank(T) < size(A,1)
error('Transformation matrix T is singular. The system may not be controllable.');
end
% Transform the system matrices
T_inv = inv(T);
A_tilde = T_inv * A * T;
B_tilde = T_inv * B;
% Extract the submatrices for the controllable part
A_c = A_tilde(1:rankC, 1:rankC);
B_c = B_tilde(1:rankC, :);
% Extract the submatrices for the uncontrollable part, if any
A_uc = A_tilde(rankC+1:end, rankC+1:end);
B_uc = B_tilde(rankC+1:end, :);
end
For higher dimension matrix:
$$
B=\begin{bmatrix}
b_1b_2b_3...b_{c_b}
\end{bmatrix}\
$$
Let's start from the first column of
If $\begin{bmatrix}
A~|b_1
\end{bmatrix}$ is not controllable, in the [last chapter](###Uncontrollable SISO Systems), we have discussed the decomposition of the controlling matrixes. So if we apply decomposition on $\begin{bmatrix}
A|b_1
\end{bmatrix}$, then we get the new controlling matrixes corresponding to |~b_1
\end{bmatrix}
\rightarrow
\begin{bmatrix}
A_{11}A_{12}|~b_{11}\
0~~~A_{22}|~~0~
\end{bmatrix}
$$
The size of b_{23}...
\end{bmatrix}
$$
So finally, the comtrolling pair can be written as:
$$
\begin{bmatrix}
A|~B
\end{bmatrix}
\rightarrow
\begin{bmatrix}
A_{11}A_{12}|~b_{11}~B_1\
0~~~A_{22}|0B_2
\end{bmatrix}
$$
Assume the rank of the controllable part
Then, it's a good way to CONTINUE using pair $\begin{bmatrix}A_{22}~|~B_2\end{bmatrix}$, to go on with this. Assume we now get a new 0~~~~K_{new}
\end{bmatrix}
$$
And if $\begin{bmatrix}A|~B_2\end{bmatrix}$ is controllable and we successfully get the 0~~~~K_{new}\
|0\
...
\end{bmatrix}
$$
And if $\begin{bmatrix}A_{22}B_2\end{bmatrix}$ is uncontrollable, we can also do decomposition and use piar $\begin{bmatrix}A_{33}|~B_3\end{bmatrix}$, till the we get the final
The author use recursion to realize this.
For a given piar
Derive:
$$
B' = BT_B
$$
This means,
However, we're facing 2 problems. The one is that, if we randomly construct a new linear combination of
One way is to make simple column exchange. For example, the folloing matrix 10\
100\
001
\end{bmatrix}
$$
Then we can get a new set of our pole place. Based on this, function myOrderedPlace(A,B,P,order)
is to make simple combination of matrix
Another way is to make combination in a more complex way. The experimenter use a sercial algorithm to realize such result:
$$
b_i\leftarrow c_1b_1+c_2b_2+...
$$
with
The built-in function place
in matlab does not support the input of uncontrollable controllability matrix pairs. The modified function realizes the pole placement of uncontrollable controllability matrix by decomposing the controllability matrix.
The built-in function place
in matlab limits the geometric multiplicity of the poles. If the geometric multiplicity of the pole matrix is greater than the geometric multiplicity of the controllability matrix, the function will not work. By using the traditional formula decomposition method, the overwritten function does not have the condition restriction of geometric multiplicity.
Most operations are operated in matlab rather than lower-level computitional languages like c
or cpp
, which restricts the speed of calculating process.
1 Joint uncontrollable part together with all-zero part.(fixed)
2 Judge dimension of each controllable part. For example, if
$A_c$ is$0\times 0$ , we need to do other operations.(fixed)3 For the uncontrollable multi-input matrix, the strategy should be changed to: first, the matrix was split into a controllable part and an uncontrollable part, and then only the controllable part was placed with poles. I'm going to put this part right here in K and I'm going to zero it out, and then I'm going to go back and transform it.(done)
24/1/1. 16:33: finished basic SISO with controllable system.
24/1/1. 19:55: finished SISO with un-controllable system, using controllibility decomposition.
24/1/2. 15:29: finished basic MIMO sisytems.
24/1/2. 18:51: fix bugs-modify
$B$ to$BT^{-1}$ when passing that matrix to the recursion body.24/1/15.21:56: Complete pole configuration under column exchange of input matrix.
24/1/17.11:10: fix bugs of using SVD to decompose a certain matrix during final exam.
24/1/18.14:01: New feature - we can place an MIMO system with random column combination of matrix B!
24/1/18.20:00: Sourcing.