如下,对一列没有初相的余弦信号和初相为pi/4的余弦信号,分别做傅里叶变换,怎么样从频谱图中看出相位信息,信号频率是50hz,采样频率是2000matlab代码如下:
clc
clear;
x = 0:0.0001:6*pi;
y1 = cos(100*pi*x+pi/4);
figure(1)
plot(x,y1,'k');
%hold on;
%对上述信号进行采样
fs = 2000;
N=128;
dt = 1/fs;
TT = (0:N-1)*dt;
X = cos(100*pi*TT+pi/4);
figure(2)
stem(TT,X);
%对采样的信号做fft
T=1/fs;
t=(0:N-1)*T;
p = X;
Y=fft(p);
magY=abs(Y(1:N/2))*2/N;%真实幅度
f=(1:N/2)'*fs/N;
angX = angle(Y(1:N/2));
figure(3)
h=stem(f,magY,'fill','--');
set(h,'MarkerEdgeColor','red','Marker','*')
grid on
title('频谱图');
xlabel('f (Hz)')
ylabel('幅值')
figure(4)
h=stem(f,angX/pi*180,'fill','--');
set(h,'MarkerEdgeColor','green','Marker','*')
grid on
title('相位谱');
xlabel('f (Hz)')
ylabel('相位')
|