-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsq_wave.py
More file actions
executable file
·29 lines (25 loc) · 555 Bytes
/
sq_wave.py
File metadata and controls
executable file
·29 lines (25 loc) · 555 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
#!/usr/bin/env python
# -*- coding:utf-8 -*-
# FileName: sq_wave.py
#
# Description:
#
# Version: 1.0
# Created: 2018-07-03 10:36:31
# Last Modified: 2019-09-03 12:19:00
# Revision: none
# Compiler: gcc
#
# Author: zt ()
# Organization:
import numpy as np
import matplotlib.pyplot as plt
t = np.linspace(-np.pi, np.pi, 201)
k = np.arange(1, float(100))
k = 2 * k - 1
f = np.zeros_like(t)
for i in range(len(t)):
f[i] = np.sum(np.sin(k * t[i]) / k)
f = (4 / np.pi) * f
plt.plot(t, f)
plt.show()