Simple sweepΒΆ
In [1]:
import matplotlib.pyplot as plt
import numpy as np
import lightlab.util.sweep as sUtil
In [2]:
# Define the system used for this notebook
class Plant():
def __init__(self):
self.x = 2
def actuateX(self, newX, rounded=False):
self.x = round(newX) if rounded else newX
def measure(self):
return np.sin(self.x)
In [3]:
p = Plant()
x = np.linspace(0,10,100)
y = sUtil.simpleSweep(p.actuateX, x, p.measure)
plt.plot(x,y)
Out[3]:
[<matplotlib.lines.Line2D at 0x10b2220b8>]
In [4]:
# Now with a lambda function
y = sUtil.simpleSweep(lambda v: p.actuateX(v, rounded=True), x, p.measure)
plt.plot(x,y)
Out[4]:
[<matplotlib.lines.Line2D at 0x10b2b9ac8>]
In [ ]: