Skip to content

Commit 7b07af3

Browse files
committed
Merge pull request #94 from murrayrm/bodefix
Bodefix
2 parents 237d1f0 + 392535c commit 7b07af3

File tree

3 files changed

+68
-64
lines changed

3 files changed

+68
-64
lines changed

control/freqplot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ def default_frequency_range(syslist, Hz=None, number_of_samples=None, feature_pe
471471

472472
# Make sure there is at least one point in the range
473473
if (features.shape[0] == 0):
474-
features = np.array([1]);
474+
features = np.array([1.]);
475475

476476
if Hz:
477477
features /= 2.*np.pi

control/tests/freqresp.py

Lines changed: 0 additions & 63 deletions
This file was deleted.

control/tests/freqresp_test.py

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
#!/usr/bin/env python
2+
#
3+
# freqresp_test.py - test frequency response functions
4+
# RMM, 30 May 2016 (based on timeresp_test.py)
5+
#
6+
# This is a rudimentary set of tests for frequency response functions,
7+
# including bode plots.
8+
9+
import unittest
10+
import numpy as np
11+
from control.statesp import StateSpace
12+
from control.matlab import ss, tf, bode
13+
import matplotlib.pyplot as plt
14+
15+
class TestFreqresp(unittest.TestCase):
16+
def setUp(self):
17+
self.A = np.matrix('1,1;0,1')
18+
self.C = np.matrix('1,0')
19+
self.omega = np.linspace(10e-2,10e2,1000)
20+
21+
def test_siso(self):
22+
B = np.matrix('0;1')
23+
D = 0
24+
sys = StateSpace(self.A,B,self.C,D)
25+
26+
# test frequency response
27+
frq=sys.freqresp(self.omega)
28+
29+
# test bode plot
30+
bode(sys)
31+
32+
# Convert to transfer function and test bode
33+
systf = tf(sys)
34+
bode(systf)
35+
36+
def test_doubleint(self):
37+
# 30 May 2016, RMM: added to replicate typecast bug in freqresp.py
38+
A = np.matrix('0, 1; 0, 0');
39+
B = np.matrix('0; 1');
40+
C = np.matrix('1, 0');
41+
D = 0;
42+
sys = ss(A, B, C, D);
43+
bode(sys);
44+
45+
def test_mimo(self):
46+
# MIMO
47+
B = np.matrix('1,0;0,1')
48+
D = np.matrix('0,0')
49+
sysMIMO = ss(self.A,B,self.C,D)
50+
51+
frqMIMO = sysMIMO.freqresp(self.omega)
52+
tfMIMO = tf(sysMIMO)
53+
54+
#bode(sysMIMO) # - should throw not implemented exception
55+
#bode(tfMIMO) # - should throw not implemented exception
56+
57+
#plt.figure(3)
58+
#plt.semilogx(self.omega,20*np.log10(np.squeeze(frq[0])))
59+
60+
#plt.figure(4)
61+
#bode(sysMIMO,self.omega)
62+
63+
def suite():
64+
return unittest.TestLoader().loadTestsFromTestCase(TestTimeresp)
65+
66+
if __name__ == '__main__':
67+
unittest.main()

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy