matlabsymbolic-mathfractionstransfer-function

Symbolic Fraction Summation with Common Denominator (MATLAB)


Hello there, hope you are all doing well.

I have two symbolic fractions with different denominators and I would like to know the result of the subtraction of them. I tried simplify and simplifyFraction functions; however they do not yield the result I want. I want the result to be in the form of A/B.

Here are the fractions and the result I get:

syms M1 M2 K1 K2 B s
T1 = (B*s + K1)/ ((M1*M2)*s^4 + (M1*B+M2*B)*s^3 + (M1*K1+M2*K1+M1*K2)*s^2 + (B*K2)*s + (K1*K2));
T = (M1*s^2 + B*s + K1) / ((M1*M2)*s^4 + (B*M1+B*M2)*s^3 + (K1*M1+K1*M2+K2*M1)*s^2 + (B*K2+B*K1-B)*s + (K1^2 -K1 + K1*K2));
T2 = T1 - T
T2 =
(K1 + B*s)/(M1*M2*s^4 + (B*M1 + B*M2)*s^3 + (K1*M1 + K1*M2 + K2*M1)*s^2 + B*K2*s + K1*K2) - (M1*s^2 + B*s + K1)/(s^3*(B*M1 + B*M2) - K1 + s^2*(K1*M1 + K1*M2 + K2*M1) + K1^2 + s*(B*K1 - B + B*K2) + K1*K2 + M1*M2*s^4)

Can you tell me which specific function I need to use to obtain the T2 in the form of A/B?


Solution

  • You can use numden to extract a numerator and denominator:

    [N,D] = numden(T2);
    

    If you then would like to obtain the polynomial coefficients (like a transfer function), you can use coeffs:

    Ncoeffs = coeffs(N,s);
    Dcoeffs = coeffs(D,s);