Search code examples
matlaboctavesymbolic-math

How to combine fractions using octave symbolic?


Does anyone know how to get Octave to combine fractions in the symbolic package? For example, I would like to make "1+1/s" rewritten as "(s^2 + 1)/s".

My reason is that I want to get zeros and poles of frequency domain expressions into the right place in the rational expression. The above is a very simple example of a more complicated use case, typically with lots of R, L, C constants.


Solution

  • You can use the function factor(), in this case it will simply put the whole expression with the same common denominator:

    syms x,s
    
    x = 1+1/s
    res = factor(x)
    

    and

    res =   
    s + 1
    ─────
      s