-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsin-input.py
42 lines (41 loc) · 1.2 KB
/
sin-input.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# -*- coding: utf-8 -*-
"""
Created on Sat Apr 29 10:18:45 2017
@author: Bernt_Lie
"""
import numpy as np
import numpy.random as nr
import matplotlib.pyplot as plt
import pandas as pd
plt.rc('text', usetex=True)
LW1 = 2.5
LW2 = LW1/2
Cb1 = (0.3,0.3,1)
Cb2 = (0.7,0.7,1)
Cg1 = (0,0.6,0)
Cg2 = (0.5,0.8,0.5)
Cr1 = "Red"
Cr2 = (1,0.5,0.5)
LS1 = "solid"
LS2 = "dotted"
LS3 = "-."
fig_path = "C:/Users/Bernt_Lie/OneDrive/Documents/booksBLSOL/LyX-test/figs/"
#
x1 = lambda t: np.exp(-10*t) - 5./20002*np.exp(10*t)*np.cos(t/10) + 250./10001*np.exp(10*t)*np.sin(t/10) - 15./202*np.exp(-10*t)*np.cos(t/10) - 75./101*np.exp(-10*t)*np.sin(t/10) + 75260./1010101
x2 = lambda t: -np.exp(-10*t) + 5./20002*np.exp(10*t)*np.cos(t/10) - 250./10001*np.exp(10*t)*np.sin(t/10) - 5./202*np.exp(-10*t)*np.cos(t/10) - 25./101*np.exp(-10*t)*np.sin(t/10) + 24750./1010101
#
t=np.linspace(0,0.6)
#
fig = plt.figure()
ax = fig.add_subplot(111)
ax.plot(t,x1(t), color=Cb1,ls=LS1, linewidth=LW1, label=r"$x_1$")
ax.plot(t,x2(t), 'r--', linewidth=LW1, label=r"$x_2$")
#
ax.set_xlabel(r"$t$")
ax.set_xlim(0,0.6)
ax.set_title(r"Solutions with input $u(t) = \sin(\frac{t}{10})$")
ax.grid()
ax.legend()
#
fig_name = "sin-input.pdf"
plt.savefig(fig_path+fig_name)