代码拉取完成,页面将自动刷新
同步操作将从 霍开拓/ComputationalPhysics 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
"""
Created on Mon Nov 11 10:15:15 2013
PHYS 613, Assignment 10
Nick Crump
"""
# Exercise 6.10
"""
Consider signals periodic in time and analyze sampling rates
using FFT to determine transformed freq spectrum of signal.
"""
import numpy as np
import FFTspectrum as fft
import matplotlib.pyplot as plt
# define freq to sample signal
sfreq = 128 # Hz
Ttot = 5 # sec
dt = 1.0/sfreq
# define time points and signal values
t = np.arange(0,Ttot+dt,dt)
f = np.cos(6*np.pi*t)
# call FFT from my module to get freq spectrum
fs,spectrum = fft.FFTspectrum(t,f,sfreq)
# print max freq found in spectrum
mx = max(spectrum)
indx = np.where(spectrum==mx)[0]
print '\n','max freq =',round(fs[indx],2)
# plot time domain signal
plt.subplot(211)
plt.plot(t,f)
plt.xlabel('Time (sec)')
plt.ylabel('Amplitude')
# plot freq domain signal
plt.subplot(212)
plt.plot(fs,spectrum, label='$128\ Hz\ sample$' +'\n' '$\ \ \ \ 3\ Hz\ freq$')
plt.xlabel('Frequency (Hz)')
plt.ylabel('Normalized Magnitude')
plt.xlim(0,20)
plt.legend()
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。