How to normalise polynomial coefficients in a fraction?

1.8k views Asked by At

I have the following code:

syms z
Gc=1.582*(1-0.3679*z^-1)/(1+.418*z^-1);
Ghp=.3679*(z^-1)*(1+.718*z^-1)/((1-z^-1)*(1-.3679*z^-1));
T=(Gc*Ghp)/(1+Gc*Ghp);
clipboard('copy', latex(simplifyFraction(T)));

Which results in following for T:

enter image description here

How can I normalise coefficients? I.e. I want the z2 in denominator and z in numerator to have the coefficient of 1. Is there any function in Matlab to do so?

1

There are 1 answers

4
AudioBubble On BEST ANSWER

You can extract the numerator and denominator with numden, then get their coefficiens with coeffs, normalize the polynomials, and divide again.

[n,d] = numden(T);
cn = coeffs(n);
cd = coeffs(d);
T = (n/cn(end))/(d/cd(end));

The output of latex(T) (note: no simplifyFraction now; it would undo things):

output

If you prefer coefficients in decimal form, use vpa(T): here is latex(vpa(T)).

vpa


Of course the above isn't equal to your original fraction, since I in effect multiplied it by cd(end)/cn(end). Depending on your purposes, you can either

  • keep the constant coefficient cn(end)/cd(end) separately in your computation, or
  • use (cn(end)/cd(end))*((n/cn(end))/(d/cd(end))); to put it back in. Unfortunately, Matlab is too eager to combine the two fractions into one, but you can still see the normalized polynomials.

new image