Skip to content

Commit cc23b83

Browse files
committed
Some temporary help files
1 parent de78c03 commit cc23b83

File tree

2 files changed

+98
-0
lines changed

2 files changed

+98
-0
lines changed

scratch/test.m

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
% -*-octave-*-
2+
% octave test file
3+
sys = ss([-2 0; 0 -1], eye(2), eye(2), zeros(2,2))
4+
5+
% convert to frd, 1 frequency
6+
fr = frd(sys, [1])
7+
8+
% the matching matrix
9+
frm = [ 0.4-0.2i 0;
10+
0 0.5-0.5i]
11+
12+
% feedback of the system itself
13+
sys2 = feedback(sys, [0 1; 3 0])
14+
15+
% and the matching fr
16+
fr2 = frd(sys2, [1])
17+
18+
fr2b = feedback(fr, [0 1; 3 0])
19+
20+
% frequency response from the matrix should be
21+
frm*inv(eye(2)+[0 1; 3 0]*frm)
22+
23+
% one with 3 out and 2 inputs, 3 states
24+
bsys = ss([-2 0 0; 0 -1 1; 0 0 -3], [1 0; 0 0; 0 1], eye(3), zeros(3,2))
25+
26+
% convert to frd, 1 frequency
27+
bfr = frd(bsys, [1])
28+
29+
% the matching matrix
30+
bfrm = [ 0.4-0.2i 0;
31+
0 0.1-0.2i;
32+
0 0.3-0.1i]
33+
34+
K = [1 0.3 0; 0.1 0 0]
35+
bsys2 = feedback(bsys, K)
36+
37+
% and the matching fr
38+
bfr2 = frd(bsys2, [1])
39+
40+
bfr2b = feedback(bfr, K)
41+
42+
% frequency response from the matrix should be
43+
bfrm*inv(eye(2)+K*bfrm)

scratch/test.py

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
from control.matlab import *
2+
import numpy as np
3+
from control.frdata import FRD as frd
4+
5+
sys = ss(np.matrix('-2 0; 0 -1'), np.eye(2), np.eye(2), np.zeros((2,2)))
6+
print sys
7+
8+
# convert to frd, 1 frequency
9+
fr = frd(sys, [1], smooth=False)
10+
print fr
11+
12+
# the matching matrix
13+
frm = np.matrix([[0.4-0.2j, 0], [0, 0.5-0.5j]])
14+
print frm
15+
16+
# feedback of the system itself
17+
sys2 = sys.feedback(np.matrix('0 1; 3 0'))
18+
print sys2
19+
20+
# and the matching fr
21+
fr2 = frd(sys2, [1], smooth=False)
22+
print fr2
23+
24+
fr2b = fr.feedback([[0, 1], [3, 0]])
25+
print fr2b
26+
27+
# frequency response from the matrix should be
28+
frm*(np.eye(2)+np.matrix('0 1.0; 3 0')*frm).I
29+
print frm
30+
31+
# one with 3 out and 2 inputs, 3 states
32+
bsys = ss(np.matrix('-2.0 0 0; 0 -1 1; 0 0 -3'), np.matrix('1.0 0; 0 0; 0 1'), np.eye(3), np.zeros((3,2)))
33+
print bsys
34+
35+
# convert to frd, 1 frequency
36+
bfr = frd(bsys, [1])
37+
print bfr
38+
39+
# the matching matrix
40+
bfrm = np.matrix('0.4-0.2j 0;0 0.1-0.2j; 0 0.3-0.1j')
41+
print bfrm
42+
43+
K = np.matrix('1 0.3 0; 0.1 0 0')
44+
bsys2 = bsys.feedback(K)
45+
print bsys2
46+
47+
# and the matching fr
48+
bfr2 = frd(bsys2, [1])
49+
print bfr2
50+
51+
bfr2b = bfr.feedback( K)
52+
print bfr2b
53+
54+
# frequency response from the matrix should be
55+
print bfrm*(np.eye(2)+K*bfrm).I

0 commit comments

Comments
 (0)