import numpy as np
import matplotlib.pyplot as plt
#1、序列的相加和相乘:
#呃,看了一早上,才发现画不出来图片的原因是我把顺序搞错了
n1=np.linspace(0,3,4,dtype=int)
x1=np.array([2,0.5,0.9,1],dtype=float)
fig=plt.figure()
ax1=fig.add_subplot(3,1,1)
ax1.stem(n1,x1)
ax1.axis([-1,9,0,2.1])
n2=np.linspace(0,7,8,dtype=int)
x2=np.linspace(0,0.7,8,dtype=float)
ax2=fig.add_subplot(3,1,2)
ax2.stem(n2,x2)
ax2.axis([-1,9,0,0.9])
n=np.linspace(0,7,8,dtype=int)
array1=np.zeros(8-len(n1))
x1=np.append(x1,array1)
x=x1+x2
ax3=fig.add_subplot(3,1,3)
ax3.stem(n,x)
ax3.axis([-1,9,0,2.1])
plt.show()
- 1
- 2
前往页