You are on page 1of 11

>> k=1;g=tf(2*k,[1 5 3 0]),h=tf([1 2],[1 8])

g =

2
-----------------
s^3 + 5 s^2 + 3 s

Continuous-time transfer function.

h =

s + 2
-----
s + 8

Continuous-time transfer function.

>> gh=series(g,h)

gh =

2 s + 4
----------------------------
s^4 + 13 s^3 + 43 s^2 + 24 s

Continuous-time transfer function.

>> k=1;g=tf(2*k,[1 5 2 0]),h=tf([1 2],[1 8])

g =

2
-----------------
s^3 + 5 s^2 + 2 s

Continuous-time transfer function.

h =

s + 2
-----
s + 8

Continuous-time transfer function.

>> gh=series(g,h)

gh =

2 s + 4
----------------------------
s^4 + 13 s^3 + 42 s^2 + 16 s

Continuous-time transfer function.

>> k=1;g=tf(2*k,[1 5 3 0]),h=tf([1 2],[1 8])


g =

2
-----------------
s^3 + 5 s^2 + 3 s

Continuous-time transfer function.

h =

s + 2
-----
s + 8

Continuous-time transfer function.

>> k=1;g=tf(2*k,[1 5 3 0]),h=tf([1 2],[1 8])

g =

2
-----------------
s^3 + 5 s^2 + 3 s

Continuous-time transfer function.

h =

s + 2
-----
s + 8

Continuous-time transfer function.

>> k=1;g=tf(2*k,[1 5 3 0]),h=tf([1 2],[1 8])

g =

2
-----------------
s^3 + 5 s^2 + 3 s

Continuous-time transfer function.

h =

s + 2
-----
s + 8

Continuous-time transfer function.

>> gh=series(g,h)

gh =
2 s + 4
----------------------------
s^4 + 13 s^3 + 43 s^2 + 24 s

Continuous-time transfer function.

>> zpk(gh)

ans =

2 (s+2)
----------------------------
s (s+8) (s+4.303) (s+0.6972)

Continuous-time zero/pole/gain model.

>> k=1;g=tf(2*k,[1 3 5 0]),h=tf([1 2],[1 8])

g =

2
-----------------
s^3 + 3 s^2 + 5 s

Continuous-time transfer function.

h =

s + 2
-----
s + 8

Continuous-time transfer function.

>> gh=series(g,h)

gh =

2 s + 4
----------------------------
s^4 + 11 s^3 + 29 s^2 + 40 s

Continuous-time transfer function.

>> zpk(gh)

ans =

2 (s+2)
----------------------
s (s+8) (s^2 + 3s + 5)

Continuous-time zero/pole/gain model.

>> bode(gh)
>> grid
>> k=10;g=tf(2*k,[1 3 5 0]),h=tf([1 2],[1 8])
g =

20
-----------------
s^3 + 3 s^2 + 5 s

Continuous-time transfer function.

h =

s + 2
-----
s + 8

Continuous-time transfer function.

>> gh=series(g,h)

gh =

20 s + 40
----------------------------
s^4 + 11 s^3 + 29 s^2 + 40 s

Continuous-time transfer function.

>> zpk(gh)

ans =

20 (s+2)
----------------------
s (s+8) (s^2 + 3s + 5)

Continuous-time zero/pole/gain model.

>> bode(gh)
>> grid
>> margin(gh)
>> grid on
>> w1=(1 2 4 7);w=[0.1*w1 w1 10*w1 100*w1 1000]
w1=(1 2 4 7);w=[0.1*w1 w1 10*w1 100*w1 1000]
|
Error: Unexpected MATLAB expression.

>> w1=[1 2 4 7];w=[0.1*w1 w1 10*w1 100*w1 1000]

w =

1.0e+03 *

Columns 1 through 9

0.0001 0.0002 0.0004 0.0007 0.0010 0.0020 0.0040 0.0070


0.0100

Columns 10 through 17
0.0200 0.0400 0.0700 0.1000 0.2000 0.4000 0.7000 1.0000

>> [mgh,fgh]=bode(gh,w)

mgh(:,:,1) =

10.0137

mgh(:,:,2) =

5.0272

mgh(:,:,3) =

2.5532

mgh(:,:,4) =

1.5154

mgh(:,:,5) =

1.1094

mgh(:,:,6) =

0.5639

mgh(:,:,7) =

0.1536

mgh(:,:,8) =

0.0401

mgh(:,:,9) =

0.0160

mgh(:,:,10) =

0.0023

mgh(:,:,11) =

3.0691e-04
mgh(:,:,12) =

5.7961e-05

mgh(:,:,13) =

1.9941e-05

mgh(:,:,14) =

2.4982e-06

mgh(:,:,15) =

3.1244e-07

mgh(:,:,16) =

5.8306e-08

mgh(:,:,17) =

1.9999e-08

fgh(:,:,1) =

-91.2942

fgh(:,:,2) =

-92.6189

fgh(:,:,3) =

-95.4772

fgh(:,:,4) =

-100.6788

fgh(:,:,5) =

-107.4299

fgh(:,:,6) =

-139.5739
fgh(:,:,7) =

-185.6405

fgh(:,:,8) =

-211.6175

fgh(:,:,9) =

-225.1246

fgh(:,:,10) =

-245.2721

fgh(:,:,11) =

-257.2499

fgh(:,:,12) =

-262.6602

fgh(:,:,13) =

-264.8526

fgh(:,:,14) =

-267.4228

fgh(:,:,15) =

-268.7110

fgh(:,:,16) =

-269.2634

fgh(:,:,17) =

-269.4843

>> i=1:17;m(i)=mgh(:,:,i),f(i)=fgh(:,:,i)

m =
Columns 1 through 9

10.0137 5.0272 2.5532 1.5154 1.1094 0.5639 0.1536 0.0401


0.0160

Columns 10 through 17

0.0023 0.0003 0.0001 0.0000 0.0000 0.0000 0.0000 0.0000

f =

Columns 1 through 9

-91.2942 -92.6189 -95.4772 -100.6788 -107.4299 -139.5739 -185.6405 -211.6175


-225.1246

Columns 10 through 17

-245.2721 -257.2499 -262.6602 -264.8526 -267.4228 -268.7110 -269.2634 -269.4843

>> [w' m' f']

ans =

1.0e+03 *

0.0001 0.0100 -0.0913


0.0002 0.0050 -0.0926
0.0004 0.0026 -0.0955
0.0007 0.0015 -0.1007
0.0010 0.0011 -0.1074
0.0020 0.0006 -0.1396
0.0040 0.0002 -0.1856
0.0070 0.0000 -0.2116
0.0100 0.0000 -0.2251
0.0200 0.0000 -0.2453
0.0400 0.0000 -0.2572
0.0700 0.0000 -0.2627
0.1000 0.0000 -0.2649
0.2000 0.0000 -0.2674
0.4000 0.0000 -0.2687
0.7000 0.0000 -0.2693
1.0000 0.0000 -0.2695

>> [w' m' 20*log10(m)' f']

ans =

1.0e+03 *

0.0001 0.0100 0.0200 -0.0913


0.0002 0.0050 0.0140 -0.0926
0.0004 0.0026 0.0081 -0.0955
0.0007 0.0015 0.0036 -0.1007
0.0010 0.0011 0.0009 -0.1074
0.0020 0.0006 -0.0050 -0.1396
0.0040 0.0002 -0.0163 -0.1856
0.0070 0.0000 -0.0279 -0.2116
0.0100 0.0000 -0.0359 -0.2251
0.0200 0.0000 -0.0526 -0.2453
0.0400 0.0000 -0.0703 -0.2572
0.0700 0.0000 -0.0847 -0.2627
0.1000 0.0000 -0.0940 -0.2649
0.2000 0.0000 -0.1120 -0.2674
0.4000 0.0000 -0.1301 -0.2687
0.7000 0.0000 -0.1447 -0.2693
1.0000 0.0000 -0.1540 -0.2695

>> w2=[1 1.1 1.2 1.3 1.4 1.5 1.6 1.7],[mgh,fgh]=bode(gh,w2);i2=1;


length(w2);m(i2)=mgh(:,:,12);f(i2)=fgh(:,:,i2);[w2' 20*log10(m)' f']

w2 =

1.0000 1.1000 1.2000 1.3000 1.4000 1.5000 1.6000 1.7000

Index exceeds matrix dimensions.

>> w2=[1 1.1 1.2 1.3 1.4 1.5 1.6 1.7],


[mgh,fgh]=bode(gh,w2);i2=1:length(w2);m(i2)=mgh(:,:,12);f(i2)=fgh(:,:,i2);[w2'
20*log10(m)' f']

w2 =

1.0000 1.1000 1.2000 1.3000 1.4000 1.5000 1.6000 1.7000

Index exceeds matrix dimensions.

>>
>>
>>
>>
>>
>>
>>
>> w2=[1 1.1 1.2 1.3 1.4 1.5 1.6 1.7],
[mgh,fgh]=bode(gh,w2);i2=1:length(w2);m(i2)=mgh(:,:,i2);f(i2)=fgh(:,:,i2);[w2'
20*log10(m)' f']

w2 =

1.0000 1.1000 1.2000 1.3000 1.4000 1.5000 1.6000 1.7000

Error using horzcat


Dimensions of matrices being concatenated are not consistent.

>> w2=[1 1.1 1.2 1.3 1.4 1.5 1.6 1.7],


[mgh,fgh]=bode(gh,w2);i2=1:length(w2);m(i2)=mgh(:,:,i2);f(i2)=fgh(:,:,i2);[w2'
20*log10(m)' f']

w2 =

1.0000 1.1000 1.2000 1.3000 1.4000 1.5000 1.6000 1.7000

Error using horzcat


Dimensions of matrices being concatenated are not consistent.
>> mgh=[],fgh=[],m=[],f=[]

mgh =

[]

fgh =

[]

m =

[]

f =

[]

>> w2=[1 1.1 1.2 1.3 1.4 1.5 1.6 1.7],


[mgh,fgh]=bode(gh,w2);i2=1:length(w2);m(i2)=mgh(:,:,i2);f(i2)=fgh(:,:,i2);[w2'
20*log10(m)' f']

w2 =

1.0000 1.1000 1.2000 1.3000 1.4000 1.5000 1.6000 1.7000

ans =

1.0000 0.9018 -107.4299


1.1000 0.1947 -110.0648
1.2000 -0.4536 -112.8871
1.3000 -1.0595 -115.8842
1.4000 -1.6369 -119.0368
1.5000 -2.1967 -122.3202
1.6000 -2.7479 -125.7044
1.7000 -3.2974 -129.1562

>> margin(gh)
>> W=feedback(g,h)

W =

20 s + 160
---------------------------------
s^4 + 11 s^3 + 29 s^2 + 60 s + 40

Continuous-time transfer function.

>> pzmap(W)
>> g=10*g

g =

200
-----------------
s^3 + 3 s^2 + 5 s

Continuous-time transfer function.

>> gh=series(g,h)

gh =

200 s + 400
----------------------------
s^4 + 11 s^3 + 29 s^2 + 40 s

Continuous-time transfer function.

You might also like