#
#
#

import pylab

class System:

	def __init__(self):
		self.x1 = 0
		self.x2 = 0

	def evaluate(self, u, delta_t):
		output = self.x1
		x1_temp = self.x1 + self.x2 * delta_t + 3 * delta_t * u
		x2_temp = 2 * delta_t * self.x1 + (1 + 3 * delta_t) * self.x2
		self.x1 = x1_temp
		self.x2 = x2_temp
		return output


_sys = System()

t = 0
delta_t = 1e-3 # 0.001 s, 1ms

u = 1 
output_array = []
time_array = []

while t < 2:

	out = _sys.evaluate(u, delta_t)

	time_array.append(t)
	output_array.append(out)

	t = t + delta_t

pylab.figure(1)
pylab.plot(time_array, output_array, 'r-+', label='y(t)')
pylab.xlabel('time')
pylab.legend()

pylab.show()

