Search code examples
matlabtransfer-function

Formatting A MATLAB Transfer Function (tf function)?


I want to input a transfer function for a PI controller in MATLAB (and eventually do a Nyquist plot of it), which has the general form:

TF = [Kp + (Ki/s)] / [x + y + z ...]

My question is, if I am using the tf() function to plot in MATLAB, how do I get KI to be divided by s instead of multiplied by it? It seems to be pretty good at assigning the appropriate power of s when I just put in the coefficients, but I'm unsure how to tell it to divide by s even after reading the documentation.

Any help would be greatly appreciated, thanks!


Solution

  • Simple...

    >> x=1    
    x =
    
         1
    
    >> y=2    
    y =
    
         2
    
    >> z=3    
    z =
    
         3
    
    >> s=tf('s')    
    s =
    
      s
    
    Continuous-time transfer function.
    
    >> Kp=1    
    Kp =
    
         1
    
    >> Ki=3    
    Ki =
    
         3
    
    >> G=(Kp+Ki/s)/(x+y+z)
    
    G =
    
      s + 3
      -----
       6 s
    
    Continuous-time transfer function.