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
:
How can I normalise coefficients? Ie I want the z 2 in denominator and z in numerator to have the coefficient of 1. Is there any function in Matlab to do so?
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):
If you prefer coefficients in decimal form, use vpa(T)
: here is latex(vpa(T))
.
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
cn(end)/cd(end)
separately in your computation, or(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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.