lab里学到的代码和输出,说实话有些不懂但留着以后能翻查
最简单的锯齿波
from scipy import signal
fs= 8000 # sampling frequency
t = np.arange(0, 2, 1/fs)# ... # time vector
f0 = 200 # frequency in Hz for scipy sawtooth
saw_tooth = signal.sawtooth(2 * np.pi * f0 * t)

傅里叶级数和锯齿波

fs=8000 # sampling frequency
t=np.arange(0,2,1/fs) # time vector
f0=2 # fundamental frequency in Hz
sin1=np.sin(2*np.pi*f0*t)
sin2=np.sin(2*np.pi*2*f0*t)/2
sin3=np.sin(2*np.pi*3*f0*t)/3
sin4=np.sin(2*np.pi*4*f0*t)/4
def generateSawTooth(f0=2, length = 2, fs=8000, order=10, height=1):
"""
Return a saw-tooth signal with given parameters.
Parameters
----------
f0 : float, optional
fundamental frequency $f_0$ of the signal to be generated,
default: 1 Hz
length : float, optional
length of the signal to be generated, default: 2 sec.
fs : float, optional
sampling frequency $f_s$, default: 8000 Hz
order : int, optional
number of sinosuids to approximate saw-tooth, default: 10
height : float, optional
height of saw-tooth, default: 1
Returns
-------
sawTooth
generated sawtooth signal
t
matching time vector
"""
t


1919

被折叠的 条评论
为什么被折叠?



