0% found this document useful (0 votes)
52 views45 pages

Ammar 142014096 Kode4

The document contains code defining state space models in MATLAB. It defines system matrices A, B, C and D, as well as numerator and denominator polynomials for three transfer functions that make up a larger overall transfer function. It then simulates the state space models and prints the state variables x1, x2 and x3 over time.

Uploaded by

Ammar Zaky
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
52 views45 pages

Ammar 142014096 Kode4

The document contains code defining state space models in MATLAB. It defines system matrices A, B, C and D, as well as numerator and denominator polynomials for three transfer functions that make up a larger overall transfer function. It then simulates the state space models and prints the state variables x1, x2 and x3 over time.

Uploaded by

Ammar Zaky
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 45

Nama : Ammar Zaky Farouk

NRP : 142014096
1.4
Pada Editor
a=[0.5 1]
b=[0.5 0]
sysG1=tf(a,b)
c=1.5
d=[0.125 0.75 1]
sysG2=tf(c,d)
e=0.3
f=[1.5 1]
sysG3=tf(e,f)
pemH=[1]
penyH=[1 5 6]
sysH=tf(pemH,penyH)
sysG=series(series(sysG1,sysG2),sysG3)
sysGH=series(sysG,sysH)

Pada Command window:


>> ammar_kode14

a=

0.5000 1.0000

b=

0.5000 0

Transfer function:
0.5 s + 1
---------
0.5 s
c=

1.5000

d=

0.1250 0.7500 1.0000

Transfer function:
1.5
----------------------
0.125 s^2 + 0.75 s + 1

e=

0.3000

f=

1.5000 1.0000

Transfer function:
0.3
---------
1.5 s + 1

pemH =
1

penyH =

1 5 6

Transfer function:
1
-------------

s^2 + 5 s + 6

Transfer function:
0.225 s + 0.45
-------------------------------------------
0.09375 s^4 + 0.625 s^3 + 1.125 s^2 + 0.5 s

Transfer function:
0.225 s + 0.45
----------------------------------------------------------------
0.09375 s^6 + 1.094 s^5 + 4.813 s^4 + 9.875 s^3 + 9.25 s^2 + 3 s

>>

Nomor 3.4
Pada Matlab :
>> ammar_state

t=

Columns 1 through 16

0 0.2000 0.4000 0.6000 0.8000 1.0000 1.2000 1.4000 1.6000


1.8000 2.0000 2.2000 2.4000 2.6000 2.8000 3.0000

Columns 17 through 32

3.2000 3.4000 3.6000 3.8000 4.0000 4.2000 4.4000 4.6000 4.8000


5.0000 5.2000 5.4000 5.6000 5.8000 6.0000 6.2000

Columns 33 through 48

6.4000 6.6000 6.8000 7.0000 7.2000 7.4000 7.6000 7.8000 8.0000


8.2000 8.4000 8.6000 8.8000 9.0000 9.2000 9.4000

Columns 49 through 64

9.6000 9.8000 10.0000 10.2000 10.4000 10.6000 10.8000 11.0000


11.2000 11.4000 11.6000 11.8000 12.0000 12.2000 12.4000 12.6000

Columns 65 through 80

12.8000 13.0000 13.2000 13.4000 13.6000 13.8000 14.0000 14.2000


14.4000 14.6000 14.8000 15.0000 15.2000 15.4000 15.6000 15.8000

Columns 81 through 96

16.0000 16.2000 16.4000 16.6000 16.8000 17.0000 17.2000 17.4000


17.6000 17.8000 18.0000 18.2000 18.4000 18.6000 18.8000 19.0000

Columns 97 through 101

19.2000 19.4000 19.6000 19.8000 20.0000


A=

1.0000 1.0000 0
0 -2.0000 1.0000
1.0000 0.5000 -2.0000

B=

1 0 0
0 -2 0
0 0 1

C=

1 0 0
0 1 0
0 0 1

D=

0 0 0
0 0 0
0 0 0

pembilang1 =

0 1.0000 4.0000 3.5000


0 0.0000 0.0000 1.0000
0 0.0000 1.0000 2.0000
penyebut1 =

1.0000 3.0000 -0.5000 -4.5000

pembilang2 =

0 -0.0000 -2.0000 -4.0000


0 -2.0000 -2.0000 4.0000
0 0.0000 -1.0000 -1.0000

penyebut2 =

1.0000 3.0000 -0.5000 -4.5000

pembilang3 =

0 0.0000 0.0000 1.0000


0 0.0000 1.0000 -1.0000
0 1.0000 1.0000 -2.0000

penyebut3 =

1.0000 3.0000 -0.5000 -4.5000

pembilang11 =

0 1.0000 4.0000

penyebut1 =
1.0000 3.0000 -0.5000

Transfer function:
s+4
---------------
s^2 + 3 s - 0.5

pembilang21 =

1.0e-014 *

0 0.0888 0.2665

penyebut1 =

1.0000 3.0000 -0.5000

Transfer function:
8.882e-016 s + 2.665e-015
-------------------------
s^2 + 3 s - 0.5

pembilang31 =

0 0.0000 1.0000

penyebut1 =
1.0000 3.0000 -0.5000

Transfer function:
4.441e-016 s + 1
----------------
s^2 + 3 s - 0.5

pembilang12 =

0 -0.0000 -2.0000

penyebut2 =

1.0000 3.0000 -0.5000

Transfer function:
-4.441e-016 s - 2
-----------------
s^2 + 3 s - 0.5

pembilang22 =

0 -2.0000 -1.0000

penyebut2 =

1.0000 3.0000 -0.5000


Transfer function:
-2 s - 1
---------------
s^2 + 3 s - 0.5

pembilang32 =

0 0.0000 -1.0000

penyebut2 =

1.0000 3.0000 -0.5000

Transfer function:
1.332e-015 s - 1
----------------
s^2 + 3 s - 0.5

pembilang13 =

1.0e-014 *

0 0.0888 0.2776

penyebut2 =
1.0000 3.0000 -0.5000

Transfer function:
8.882e-016 s + 2.776e-015
-------------------------
s^2 + 3 s - 0.5

pembilang23 =

1.0e-014 *

0 0.0888 0.2776

penyebut3 =

1.0000 3.0000 -0.5000

Transfer function:
8.882e-016 s + 2.776e-015
-------------------------
s^2 + 3 s - 0.5

pembilang33 =

0 1.0000 1.0000

penyebut3 =

1.0000 3.0000 -0.5000


Transfer function:
s+1
---------------
s^2 + 3 s - 0.5

x1 =

0
0.2171
0.4601
0.7209
0.9954
1.2815
1.5784
1.8856
2.2032
2.5311
2.8698
3.2194
3.5802
3.9527
4.3372

4.7341
5.1438
5.5666
6.0030
6.4535
6.9184
7.3983
7.8937
8.4050
8.9327
9.4774
10.0396
10.6200
11.2189
11.8372
12.4753
13.1340
13.8139
14.5156
15.2399
15.9875
16.7592
17.5556
18.3778
19.2263
20.1021
21.0062
21.9393
22.9024
23.8965
24.9226
25.9817
27.0748

28.2031
29.3678
30.5698
31.8106
33.0913
34.4131
35.7775
37.1858
38.6394
40.1397
41.6883
43.2868
44.9366
46.6395
48.3972
50.2115
52.0841
54.0170
56.0120
58.0712
60.1966
62.3905
64.6549
66.9921
69.4045
71.8946
74.4647
77.1175
79.8556
82.6819
85.5990
88.6100
91.7179

94.9257
98.2367
101.6543
105.1817
108.8227
112.5808
116.4598
120.4635
124.5961
128.8615
133.2643
137.8086
142.4991
147.3405
152.3377
157.4956
162.8195
168.3146
173.9864
179.8408

x2 =

1.0e-012 *

0
0.0002
0.0004
0.0005
0.0007
0.0009
0.0011

0.0013
0.0016
0.0018
0.0020
0.0022
0.0025
0.0027
0.0030
0.0033
0.0035
0.0038
0.0041
0.0044
0.0047
0.0051
0.0054
0.0057
0.0061
0.0065
0.0068
0.0072
0.0076
0.0081
0.0085
0.0089
0.0094
0.0099
0.0103
0.0109
0.0114
0.0119
0.0125
0.0130
0.0136

0.0142
0.0149
0.0155
0.0162
0.0169
0.0176
0.0183
0.0191
0.0199
0.0207
0.0215
0.0224
0.0233
0.0242
0.0252
0.0261
0.0271
0.0282
0.0293
0.0304
0.0315
0.0327
0.0339
0.0352
0.0365
0.0379
0.0392
0.0407
0.0422
0.0437
0.0453
0.0469
0.0486
0.0503

0.0521
0.0539
0.0558
0.0578
0.0598
0.0619
0.0641
0.0663
0.0686
0.0710
0.0735
0.0760
0.0786
0.0813
0.0841
0.0870
0.0900
0.0930
0.0962
0.0995
0.1028
0.1063
0.1099
0.1136
0.1174
0.1214

x3 =

0
0.0166
0.0560
0.1087

0.1693
0.2353
0.3052
0.3782
0.4542
0.5328
0.6141
0.6981
0.7849
0.8744
0.9669
1.0623
1.1608
1.2625
1.3675
1.4758
1.5876
1.7030
1.8221
1.9451
2.0720
2.2030
2.3382
2.4778
2.6218
2.7705
2.9240
3.0824
3.2458
3.4146
3.5888
3.7686
3.9541
4.1457

4.3434
4.5474
4.7581
4.9755
5.1999
5.4315
5.6705
5.9173
6.1720
6.4349
6.7062
6.9863
7.2754
7.5737
7.8817
8.1996
8.5277
8.8664
9.2159
9.5767
9.9492
10.3336
10.7303
11.1398
11.5625
11.9988
12.4492
12.9140
13.3937
13.8889
14.4001
14.9277
15.4722
16.0343

16.6144
17.2132
17.8313
18.4692
19.1277
19.8074
20.5089
21.2330
21.9804
22.7518
23.5480
24.3699
25.2182
26.0938
26.9975
27.9304
28.8932
29.8870
30.9128
31.9715
33.0644
34.1924
35.3566
36.5584
37.7987
39.0790
40.4005
41.7645
43.1724

x4 =

0
-0.0331
-0.1121
-0.2173
-0.3386
-0.4706
-0.6103
-0.7565
-0.9083
-1.0656
-1.2282
-1.3963
-1.5698
-1.7489
-1.9338
-2.1247
-2.3217
-2.5250
-2.7349
-2.9516
-3.1752
-3.4060
-3.6443
-3.8902
-4.1440
-4.4060
-4.6764
-4.9555
-5.2436
-5.5410
-5.8479
-6.1647

-6.4917
-6.8292
-7.1776
-7.5371
-7.9083
-8.2914
-8.6868
-9.0949
-9.5161
-9.9509
-10.3997
-10.8629
-11.3411
-11.8346
-12.3440
-12.8697
-13.4124
-13.9726
-14.5507
-15.1475
-15.7634
-16.3992
-17.0554
-17.7328
-18.4319
-19.1535
-19.8983
-20.6671
-21.4606
-22.2797
-23.1251
-23.9977
-24.8983
-25.8279

-26.7875
-27.7779
-28.8002
-29.8553
-30.9444
-32.0685
-33.2288
-34.4264
-35.6626
-36.9385
-38.2554
-39.6148
-41.0178
-42.4660
-43.9607
-45.5036
-47.0961
-48.7398
-50.4364
-52.1876
-53.9951
-55.8607
-57.7864
-59.7740
-61.8255
-63.9431
-66.1287
-68.3847
-70.7133
-73.1167
-75.5975
-78.1581
-80.8010

-83.5290
-86.3447

x5 =

0
-0.3184
-0.5280
-0.6811
-0.8056
-0.9161
-1.0207
-1.1236
-1.2272
-1.3326
-1.4407
-1.5518
-1.6663
-1.7844
-1.9062
-2.0319
-2.1616
-2.2955
-2.4337
-2.5763
-2.7235
-2.8755
-3.0323
-3.1942
-3.3613
-3.5338
-3.7118
-3.8955

-4.0852
-4.2809
-4.4830
-4.6916
-4.9068
-5.1290
-5.3583
-5.5950
-5.8394
-6.0916
-6.3518
-6.6205
-6.8978
-7.1841
-7.4795
-7.7845
-8.0992
-8.4241
-8.7594
-9.1056
-9.4628
-9.8316
-10.2122
-10.6050
-11.0105
-11.4290
-11.8610
-12.3069
-12.7672
-13.2422
-13.7326
-14.2387
-14.7610
-15.3002

-15.8568
-16.4312
-17.0241
-17.6361
-18.2678
-18.9198
-19.5927
-20.2874
-21.0043
-21.7444
-22.5082
-23.2966
-24.1104
-24.9503
-25.8173
-26.7121
-27.6358
-28.5891
-29.5732
-30.5888
-31.6372
-32.7193
-33.8361
-34.9890
-36.1789
-37.4070
-38.6747
-39.9832
-41.3338
-42.7278
-44.1666
-45.6518
-47.1847
-48.7669

-50.4000
-52.0857
-53.8256
-55.6214
-57.4750

x6 =

0
-0.0166
-0.0560
-0.1087
-0.1693
-0.2353
-0.3052
-0.3782
-0.4542
-0.5328
-0.6141
-0.6981
-0.7849
-0.8744
-0.9669
-1.0623
-1.1608
-1.2625
-1.3675
-1.4758
-1.5876
-1.7030
-1.8221
-1.9451
-2.0720

-2.2030
-2.3382
-2.4778
-2.6218
-2.7705
-2.9240
-3.0824
-3.2458
-3.4146
-3.5888
-3.7686
-3.9541
-4.1457
-4.3434
-4.5474
-4.7581
-4.9755
-5.1999
-5.4315
-5.6705
-5.9173
-6.1720
-6.4349
-6.7062
-6.9863
-7.2754
-7.5737
-7.8817
-8.1996
-8.5277
-8.8664
-9.2159
-9.5767
-9.9492

-10.3336
-10.7303
-11.1398
-11.5625
-11.9988
-12.4492
-12.9140
-13.3937
-13.8889
-14.4001
-14.9277
-15.4722
-16.0343
-16.6144
-17.2132
-17.8313
-18.4692
-19.1277
-19.8074
-20.5089
-21.2330
-21.9804
-22.7518
-23.5480
-24.3699
-25.2182
-26.0938
-26.9975
-27.9304
-28.8932
-29.8870
-30.9128
-31.9715
-33.0644

-34.1924
-35.3566
-36.5584
-37.7987
-39.0790
-40.4005
-41.7645
-43.1724

x7 =

1.0e-012 *

0
0.0002
0.0004
0.0006
0.0008
0.0010
0.0012
0.0014
0.0016
0.0018
0.0021
0.0023
0.0026
0.0028
0.0031
0.0034
0.0037
0.0040
0.0043
0.0046

0.0049
0.0052
0.0056
0.0060
0.0063
0.0067
0.0071
0.0075
0.0079
0.0084
0.0088
0.0093
0.0097
0.0102
0.0107
0.0113
0.0118
0.0124
0.0129
0.0135
0.0142
0.0148
0.0154
0.0161
0.0168
0.0175
0.0183
0.0190
0.0198
0.0207
0.0215
0.0224
0.0233
0.0242

0.0251
0.0261
0.0272
0.0282
0.0293
0.0304
0.0316
0.0328
0.0340
0.0353
0.0366
0.0379
0.0393
0.0408
0.0423
0.0438
0.0454
0.0470
0.0487
0.0505
0.0523
0.0541
0.0561
0.0580
0.0601
0.0622
0.0644
0.0666
0.0690
0.0713
0.0738
0.0764
0.0790
0.0817

0.0845
0.0874
0.0904
0.0935
0.0967
0.1000
0.1034
0.1069
0.1105
0.1142
0.1181
0.1221
0.1262

x8 =

1.0e-012 *

0
0.0002
0.0004
0.0006
0.0008
0.0010
0.0012
0.0014
0.0016
0.0018
0.0021
0.0023
0.0026
0.0028
0.0031

0.0034
0.0037
0.0040
0.0043
0.0046
0.0049
0.0052
0.0056
0.0060
0.0063
0.0067
0.0071
0.0075
0.0079
0.0084
0.0088
0.0093
0.0097
0.0102
0.0107
0.0113
0.0118
0.0124
0.0129
0.0135
0.0142
0.0148
0.0154
0.0161
0.0168
0.0175
0.0183
0.0190
0.0198

0.0207
0.0215
0.0224
0.0233
0.0242
0.0251
0.0261
0.0272
0.0282
0.0293
0.0304
0.0316
0.0328
0.0340
0.0353
0.0366
0.0379
0.0393
0.0408
0.0423
0.0438
0.0454
0.0470
0.0487
0.0505
0.0523
0.0541
0.0561
0.0580
0.0601
0.0622
0.0644
0.0666
0.0690
0.0713
0.0738
0.0764
0.0790
0.0817
0.0845
0.0874
0.0904
0.0935
0.0967
0.1000
0.1034
0.1069
0.1105
0.1142
0.1181
0.1221
0.1262

x9 =

0
0.1675
0.2920
0.3949
0.4874
0.5757
0.6629
0.7509
0.8407
0.9327
1.0274
1.1250
1.2256
1.3294
1.4365
1.5471
1.6612
1.7790
1.9006
2.0261
2.1556
2.2893
2.4272
2.5697
2.7167
2.8684
3.0250
3.1867
3.3535
3.5257
3.7035
3.8870
4.0763
4.2718
4.4736
4.6818
4.8968
5.1186
5.3476
5.5840
5.8279
6.0798
6.3397
6.6080
6.8849
7.1707

7.4657
7.7702
8.0845
8.4089
8.7438
9.0894
9.4461
9.8143
10.1944
10.5867
10.9916
11.4095
11.8409
12.2861
12.7457
13.2200
13.7097
14.2150
14.7366
15.2750
15.8308
16.4044
16.9964
17.6075
18.2383
18.8893
19.5613
20.2549
20.9708
21.7098
22.4725
23.2598
24.0723
24.9111

25.7768
26.6703
27.5926
28.5446
29.5272
30.5414
31.5882
32.6687
33.7840
34.9351
36.1233
37.3497
38.6155
39.9221
41.2706
42.6626
44.0994
45.5824
47.1130
48.6930
50.3237
Grafik:
2.4
>> discrete

T=

Columns 1 through 7

0 0.2500 0.5000 0.7500 1.0000 1.2500 1.5000

Columns 8 through 14

1.7500 2.0000 2.2500 2.5000 2.7500 3.0000 3.2500

Columns 15 through 21

3.5000 3.7500 4.0000 4.2500 4.5000 4.7500 5.0000

Columns 22 through 28

5.2500 5.5000 5.7500 6.0000 6.2500 6.5000 6.7500

Columns 29 through 35

7.0000 7.2500 7.5000 7.7500 8.0000 8.2500 8.5000

Columns 36 through 42

8.7500 9.0000 9.2500 9.5000 9.7500 10.0000 10.2500

Columns 43 through 49

10.5000 10.7500 11.0000 11.2500 11.5000 11.7500 12.0000

Columns 50 through 56
12.2500 12.5000 12.7500 13.0000 13.2500 13.5000 13.7500

Columns 57 through 63

14.0000 14.2500 14.5000 14.7500 15.0000 15.2500 15.5000

Columns 64 through 70

15.7500 16.0000 16.2500 16.5000 16.7500 17.0000 17.2500

Columns 71 through 77

17.5000 17.7500 18.0000 18.2500 18.5000 18.7500 19.0000

Columns 78 through 81

19.2500 19.5000 19.7500 20.0000

pemG =

0 1

a=

1 0

b=

1.0000 0.2500

c=
1.0000 0.0830 -0.0830

penG =

1.0000 0.3330 -0.0623 -0.0208 0

Ts =

0.2500

Syscont =

1
-----------------------------------------
s^4 + 0.333 s^3 - 0.06225 s^2 - 0.02075 s

Continuous-time transfer function.

Sysd =

0.0001601 z^3 + 0.001733 z^2 + 0.001704 z + 0.0001523


-----------------------------------------------------
z^4 - 3.924 z^3 + 5.768 z^2 - 3.764 z + 0.9201

Sample time: 0.25 seconds


Discrete-time transfer function.

pemb =

1 -24 192
peny =

1 24 192

Sysp =

s^2 - 24 s + 192
----------------
s^2 + 24 s + 192

Continuous-time transfer function.

Sysi =

1
-
s

Continuous-time transfer function.

Sys1 =

48 s
--------------------
s^3 + 24 s^2 + 192 s

Continuous-time transfer function.

Siso =

48 s
---------------------------------------------------------------
s^7 + 24.33 s^6 + 199.9 s^5 + 62.42 s^4 - 12.45 s^3 - 3.984 s^2

Continuous-time transfer function.

Sysc =

48 s

-----------------------------------------------------------------

s^7 + 24.33 s^6 + 199.9 s^5 + 62.42 s^4 - 12.45 s^3 - 3.984 s^2

+ 48 s

Continuous-time transfer function.

Sys =

0.0001601 z^3 + 0.001733 z^2 + 0.001704 z + 0.0001523


-----------------------------------------------------
z^4 - 3.924 z^3 + 5.77 z^2 - 3.762 z + 0.9203

Sample time: 0.25 seconds


Discrete-time transfer function.
>>

You might also like