# How can I fix this Error?

17 views (last 30 days)
Uzair Wasim Mukadam on 8 Jan 2022
Commented: Paul on 10 Jan 2022
G=[tf([1 -1],[1 5 6]), tf([0 4],[1 3]);tf([1,0],[1 5 6]), tf([1,0],[1 2])];
s=tf('s');
disp(G);
ss_G=ss(G);
A=ss_G.A;
B=ss_G.B;
C=ss_G.C;
D=ss_G.D;
n=size(A,1); %%No. of States of A in form nxn
%%eig(A) if all negative then system is stable
c=rank(ctrb(A,B));
o=rank(obsv(A,C));
if c==n && o==n
disp('Since SS model is Both Controllable and Observable. Hence is minimal state-space realised');
else
disp('Not Gilbert Realised State');
end
I've been assigned the Task to develop an algorithm for rearranging the transfer function matrix to a minimal state-space realisation for a MIMO T.F. matrix G(s) with no repeated poles based on the Gilbert realisation for state-space models as a Matlab Function.
The above is my attempt towards checking the Gilbert realisation condition i.e., it should be Controllable and Observable both. I've been confused as to how to do it for a MIMO system as in the case above. Basically develop my own function for ss() which incorporates Gilbert's Realization. I'd be glad if anyone could guide me in the right direction or tips for the above.
Paul on 10 Jan 2022
Why did you change the title of the Qeustion?

Paul on 8 Jan 2022
Edited: Paul on 8 Jan 2022
Let's look at what we have so far with a sight change in notation that might make it clearer to read and a path to a general solution.
G=tf({1 1;1 [1 -2]},{[1 2] [1 2];[1 -2] [1 3 2]});
[r11 p11 k11]=residue(G(1,1).num{:},G(1,1).den{:});
[r12 p12 k12]=residue(G(1,2).num{:},G(1,2).den{:});
[r21 p21 k21]=residue(G(2,1).num{:},G(2,1).den{:});
[r22 p22 k22]=residue(G(2,2).num{:},G(2,2).den{:});
Now, in principal, each rij should have three residues, i.e., one for each of the three poles of the system at p = {-1, 2, -2}. So to find R1 corresponding to p = -1, for example, you'd find each residue of rij that corresponds to p = -1, and construct R1 like this
R1 = [r11(p11==-1) r12(p12==-1); r21(p21==-1) r22(p22==-1)];
Of course you'll want first find the system poles p, and then loop over that vector to find the R's. Also, keep in mind that you might need to use a tolerlance check to find which element of pij corresponds to an element of p. That is, the way you compute p and they way that residue computes pij might not be exactly equivalent to full precision.
But there is a wrinkle. The way you're doing this, each rij will only have residues that correspond to the poles in pij, which could be only a subset of the three poles of the system. For example, look at r11 and p11
r11,p11
r11 = 1
p11 = -2
So the values of r11 that correspond to p = -1 and to p = 2 are (implicitly) zero, and you'll have to account for that in your construction of R1 and R2.
Hope this helps to get you further along. Feel free to follow up if clarifciation is needed or if you need more suggestions on the steps that follow finding the residue matrices.
Also, the algorthm in the pictures you posted assumes that the D-matrix of the realization of G is zero, whch is the case for the example here, but would not be the case in general.
Uzair Wasim Mukadam on 10 Jan 2022
Thanks for your input. I'll try to implement the entire algoritihm and get back to you.

R2020b

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!