-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBasicExercise 10.py
More file actions
45 lines (34 loc) · 1012 Bytes
/
BasicExercise 10.py
File metadata and controls
45 lines (34 loc) · 1012 Bytes
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
43
#!/usr/bin/env python2.6
#_*_coding:utf8_*_
import numpy as np
import matplotlib
matplotlib.use("TkAgg")
import matplotlib.pyplot as plt
from time import sleep
#para no presionar enter la pc lo hacecada cierto tiempo
fig=plt.figure()
ax=fig.add_subplot(111)
ax.plot([],[])
ax.grid()
#variables
n = range(0,10)
tvec = np.linspace(-2*np.pi,2*np.pi,500)
#ax.plot(tvec,np.sin(tvec))
ax.set_ylim(1,-1)
def termT(i):
f = ((2*i)+1)
result = (4/(f*np.pi))
return result
def animacion():
four = np.zeros(len(tvec))
for i in n:
print i
four += termT(i)*np.sin(((2*i)+1)*tvec)#suma cada t\303\251rmino de la serie
ax.plot(tvec,four)
ax.set_xlim(-2*np.pi,2*np.pi)
ax.set_ylim(-1.3,1.3)#rangos de x e y
sleep(0.5)#se muestra cada 5 segundos
fig.canvas.draw()#redibuja
win= fig.canvas.manager.window
fig.canvas.manager.window.after(10,animacion)
plt.show()