Combining Fractions in Matlab

Discussion in 'Programmer's Corner' started by TierOne, Mar 28, 2011.

  1. TierOne

    Thread Starter New Member

    Feb 5, 2011
    16
    2
    hi all, is someone kind enough to show me how to combine the following into one fraction in matlab?

    example:
    y=1/x + 1/x^2 + 1/x^3 + x/(1-x^2)
    i need:
    y=X1/X2 where X1 and X2 are function of x
     
  2. Georacer

    Moderator

    Nov 25, 2009
    5,142
    1,266
    Is it for a general purpose fraction or are you interested in Transfer Function transformations? For that purpose there is the zpk(tf) command.

    If you are interested in general fractions, you can use "factor(syms)" to collect the terms in the nominator and denominator and then use "expand(syms)" to expand them manually.

    Does that cover your needs?
     
  3. TierOne

    Thread Starter New Member

    Feb 5, 2011
    16
    2
    this is for general fractions. The solution is for symbols created using tf(). Thanks for the thought!
     
  4. Georacer

    Moderator

    Nov 25, 2009
    5,142
    1,266
    The first solution is for transfer function lti objects only. The second paragraph does apply to your problem.
     
    TierOne likes this.
  5. TierOne

    Thread Starter New Member

    Feb 5, 2011
    16
    2
    tried and worked

    THANK YOU!

     
    Georacer likes this.
Loading...