+ Post New Thread
Results 1 to 3 of 3
  1. #1
    Advanced Member level 5
    Points: 17,282, Level: 31
    pancho_hideboo's Avatar
    Join Date
    Oct 2006
    Location
    Real Homeless
    Posts
    2,665
    Helped
    715 / 715
    Points
    17,282
    Level
    31

    How to generate H(-s) in MATLAB

    Assume that I have transfer function, H(s).
    Here I would like to generate H(-s) smartly.

    Now I use following MATLAB code for this purpose.
    Here I use "Control System Toolbox".
    However it is not cool at all.

    I will not use "Symbolic Math Toolbox".

    Is there any cool method ?
    Code:
    >> s=tf('s')
     
    Transfer function:
    s
     
    >> H=(s^2+s^1+3)/(s^3+s^2+s+2)
    
    Transfer function:
       s^2 + s + 3
    -----------------
    s^3 + s^2 + s + 2
     
    >> [z, p, k] = zpkdata(H, 'v')
    
    z =
    
      -0.5000 + 1.6583i
      -0.5000 - 1.6583i
    
    
    p =
    
      -1.3532          
       0.1766 + 1.2028i
       0.1766 - 1.2028i
    
    
    k =
    
         1
    
    >> num_zeros = length(z)
    
    num_zeros =
    
         2
    
    >> num_poles = length(p)
    
    num_poles =
    
         3
    
    >> if mod(num_zeros+num_poles, 2) == 0
    zpk(-z, -p, k)
    else
    zpk(-z, -p, -k)
    end
     
    Zero/pole/gain:
             - (s^2 - s + 3)
    ---------------------------------
    (s-1.353) (s^2 + 0.3532s + 1.478)
     
    >>

    Code:
    >> s=tf('s')
     
    Transfer function:
    s
     
    >> H=(s^2+s^1+3)/(s^3+s^2+s+2)
     
    Transfer function:
       s^2 + s + 3
    -----------------
    s^3 + s^2 + s + 2
     
    >> [num, den] = tfdata(H, 'v')
    
    num =
    
         0     1     1     3
    
    
    den =
    
         1     1     1     2
    
    >> for(i=1:length(num))
    if mod(i+length(num), 2) == 1, num(i) = -num(i); end
    end
    >> for(i=1:length(den))
    if mod(i+length(den), 2) == 1, den(i) = -den(i); end
    end
    >> tf(num, den)
     
    Transfer function:
      -s^2 + s - 3
    -----------------
    s^3 - s^2 + s - 2
     
    >>

    •   AltAdvertisement

        
       

  2. #2
    Advanced Member level 2
    Points: 2,970, Level: 12

    Join Date
    Aug 2016
    Posts
    518
    Helped
    88 / 88
    Points
    2,970
    Level
    12

    Re: How to generate H(-s) in MATLAB

    Hi,

    Provide a little more detail of what you want to do, especially on H(-s).
    -------------
    --Akanimo.



    •   AltAdvertisement

        
       

  3. #3
    Advanced Member level 5
    Points: 17,282, Level: 31
    pancho_hideboo's Avatar
    Join Date
    Oct 2006
    Location
    Real Homeless
    Posts
    2,665
    Helped
    715 / 715
    Points
    17,282
    Level
    31

    Re: How to generate H(-s) in MATLAB

    Quote Originally Posted by Akanimo View Post
    Provide a little more detail of what you want to do, especially on H(-s).
    For example, decompisition of H(s) to even and odd components.

    H(s) = Heven(s) + Hodd(s)
    Heven(s) = {H(s) + H(-s)} / 2
    Hodd(s) = {H(s) - H(-s)} / 2



--[[ ]]--