How do I make a minimal realization of a transfer function?

Let's say that I have this transfer function.

$$G (s) = \frac {s^4 + 4s^3 + 7s^2 + 10s + 8}{s^5 + 6s^4 + 15s^3 + 25s^2 + 32s + 20}$$

And with MATLAB function minreal, I can get this transfer function

$$G_{min} (s) = \frac {s^3 + 2s^2 + 3s + 4}{s^4 + 4s^3 + 7s^2 + 11s +10}$$

If I have the numerators and denomerators from $G (s)$ in two vectors $num, den$. Which MATLAB command should I use to cansle out poles against zeros so I can get the minimal realization?

I have the poles and zeros in two separate vectors. How can I (easy) use MATLAB 's smart functions to check if I have equation zeros and poles and I have, remove them.

The command you are looking for is minreal:

num = [1, 4, 7, 10, 8];
den = [1, 6, 15, 25, 32, 20];

G = tf(num, den);

tol = 1.0e-9;

G_min = minreal(G, tol);


Gives you the desired minimal realization. Here, tol is the tolerance which is used for comparing poles and zeros.

• I know. But I trying to cansle out zeros with poles, then use zpk function . – Daniel Mårtensson Oct 15 '17 at 11:05
• If you know, why do you ask then? I don't see how zpk is related to this. You can of course use zpk on both $G$ and $G_{\text{min}}$. The first will contain all poles and zeros, the second will only contain those that were not cancelled out, just as one would expect. – SampleTime Oct 15 '17 at 11:09
• Here is my question "If I have the numerators and denomerators from$G (s)$num,den\$. Which MATLAB command should I use to cansle out poles against zeros so I can get the minimal realization? I have the poles and zeros in two separate vectors. How can I (easy) use MATLAB 's smart functions to check if I have equation zeros and poles and I have, remove them." – Daniel Mårtensson Oct 15 '17 at 11:14
• Thats exactly the same question as in the original post which I already answered: use minreal. – SampleTime Oct 15 '17 at 11:44
• I posted the answer here now. :) – Daniel Mårtensson Oct 15 '17 at 11:45

>> [a,b,c] = intersect(round(z*1/tol)*tol, round(p*1/tol)*tol)