python复数转化为相位角,Scipy FFT-如何获得相位角

本文探讨了使用Python的Scipy FFT模块计算简单正弦波相位角时遇到的问题。代码示例展示了如何正确计算相位角,并强调了在处理离散傅里叶变换时信号周期的重要性。
摘要由CSDN通过智能技术生成

I'm having trouble getting the phase of a simple sine curve using the scipy fft module in python. I followed this tutorial closely and converted the matlab code to python. However, no matter what phase I use for the input, the graph always shows 3. What am I missing?

import numpy as np

import matplotlib.pyplot as plt

import scipy.fftpack

import cmath

A=10

fc = 10

phase=60

fs=32#Sampling frequency with oversampling factor of 32

t = np.arange(0,2,1/fs)

#Convert the phase shift to radians from degrees.

phi = phase*np.pi/180

x=A*np.cos(2*np.pi*fc*t+phi)

N=256

X = scipy.fftpack.fftshift(scipy.fftpack.fft(x,N))/N

df=fs/N #Frequency resolution.

sampleindex = np.arange(-N/2,N/2,1) #Ordered index for FFT plot.

f &

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值