How to generate H(-s) in MATLAB

Status
Not open for further replies.

pancho_hideboo

Advanced Member level 5
Joined
Oct 21, 2006
Messages
2,847
Helped
767
Reputation
1,536
Reaction score
733
Trophy points
1,393
Location
Real Homeless
Activity points
17,490
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
 
>>
 

Hi,

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

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
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…