如何绘制公式图:x(t)= cos(2π·10t)+ cos(2π·25t)+ cos(2π·50t)+ cos(2π·100t)
答案 0 :(得分:3)
这很简单:声明你的t数组,计算x(t)数组,用matplotlib绘制它。
import numpy as np
import matplotlib.pyplot as plt
# Declare t array
t = np.arange(0.0,2.0,0.01) # change your end point and step as you want it
# Compute x(t) with numpy
x = np.cos(2*np.pi*10*t) + np.cos(2*np.pi*25*t) + np.cos(2*np.pi*50*t) + np.cos(2*np.pi*100*t)
# Plot t with x
plt.plot(t,x)
plt.show()