一、 实验目的
验证离散傅里叶变换的性质,包括线性特性、时移特性、频移特性、对称性和循环卷积等性质。
二、 实验内容
取两个序列为:x1[n]=[1 9 9 9 0 5 2 5],x2[n]=[2 0 2 0 0 5 0 2],序列的幅度谱和相位谱见下:
验证下列性质:
1.线性特性
由图可得两序列之和的幅度谱和相位谱与两序列幅度谱相位谱之和分别相同。
结论:两序列之和的傅里叶变化和两序列的傅里叶变化之和相等,即离散傅里叶变换有线性特性。
2.时移特性
求其x1[n]= [1 9 9 9 0 5 2 5]右移三位得其频谱,并与原序列的频谱进行比较。
两者的比较见下:
由上图可得:序列进行右移后,其幅度谱与原来的幅度谱一样。
结论:序列右移不会改变原来序列的幅度谱,但其相位谱发生了变化。
3.对称性
⑴用序列x1 = [1 9 9 9 0 5 2 5],进行验证。
得其共轭对称部分和共轭反对称部分的频谱见下:
结论:序列是有共轭对称部分和共轭反对称部分组成,其频谱也是由其共轭对称部分和共轭反对称部分组成。
⑵验证奇对称序列和偶对称序列的频谱
结论:偶对称序列频谱只有实部,奇对称序列的频谱只有虚部。
4.其它性质:频移特性
用序列x1 = [1 9 9 9 0 5 2 5],对频移特性进行验证。
结论:频移后时域序列幅度不变,相位发生变化
5.直流信号的fft和正弦信号的fft
结论:直流流信号的fft只在一点有值不为0,正弦信号的fft只在两点值不为0。但在实验过程中发现,若序列点数不为周期整数倍,fft后频谱有缓坡,增大点数可减小缓坡。
附-实验源码
1线性特性
x1 = [1 9 9 9 0 5 2 5];
x2 = [2 0 0 0 0 5 0 2];
f_x1 = fft(x1,8);
f_x2 = fft(x2,8);
x_axis = [ 0: 1: 7 ];
figure(1);
subplot( 3, 2, 1 );
stem( x_axis, x1, '.' );
xlabel( 'n' ); title('序列x1');
subplot( 3,2,3 );
stem( x_axis, abs(f_x1),'.' ); grid on;
xlabel( '频率 k' ); ylabel( 'f_x1幅度');
title( 'f_x1幅度谱' );
subplot( 3,2,5 );
stem( x_axis, angle(f_x1),'.' ); grid on;
xlabel( '频率 k' ); ylabel( 'f_x1相位' );
title( 'f_x1相位谱' );
subplot( 3,2,2 );
stem( x_axis, x2, '.' );
xlabel( 'n' ); title('时间序列x2');
subplot( 3,2,4 );
stem( x_axis, abs(f_x2),'.'); grid on;
xlabel( '频率 k' ); ylabel( 'f_x2幅度' );
title( 'f_x2幅度谱' );
subplot( 3,2,6 );
stem( x_axis, angle(f_x2),'.' ); grid on;
xlabel( '频率 k' ); ylabel( 'f_x2相位' );
title( 'f_x2相位谱' );
% 2 验证DFT的线性性质
x_sum1 = 2*x1 + 6*x2;
f_x_sum1 = fft( x_sum1, 8 );
figure(2);
subplot(2,2,1);
stem( x_axis, abs(f_x_sum1),'.');
title( '序列之和的幅度谱' );
subplot(2,2,3);
stem( x_axis, angle(f_x_sum1),'.' );
title( '序列之和的相位谱' );
f_sum1 = 2*f_x1 + 6*f_x2;
subplot(2,2,2);
stem( x_axis, abs(f_sum1), '.' );
title( '序列幅度谱之和' );
subplot(2,2,4);
stem( x_axis, angle(f_sum1), '.' );
title( '序列相位谱之和' );
2时移特性
x_axis = [ 0: 1: 7 ];
%x = x_axis.^2 ;
x=[1,9,9,9,0,5,2,5];
x = x'; % 必须是列向量,才进行移位
figure(1);
subplot(3,1,1);
stem( x_axis, x, '.' );
xlabel( 'n' ); title( '原始序列' );
x_r = circshift( x, 3 ); % 正数右移,负数左移
subplot(3,1,2);
stem( x_axis, x_r ,'*' );
xlabel( 'n' ); title( '序列右移3个单元' );
fft_x = fft( x );
fft_x_r = fft( x_r );
figure(2);
subplot(3,1,1);
stem( x_axis, x, '.' );
title( '原始序列' );
subplot(3,1,2);
stem( x_axis, abs(fft_x), '.' );
title( '原序列幅度谱' );
subplot(3,1,3);
stem( x_axis, abs(fft_x_r), '.' );
title( '右移后幅度谱' );
figure(3);
subplot(3,1,1);
stem( x_axis, x, '.' );
title( '原始序列' );
subplot(3,1,2);
stem( x_axis, angle(fft_x), '.' );
title( '原序列相位谱' );
subplot(3,1,3);
stem( x_axis, angle(fft_x_r), '.' );
title( '右移后相位谱' );
% 对移动的位移进行估计
% R_Shift_Calc = ( angle(fft_x5(2)) - angle(fft_x5_r(2)) ) * 8 /2/pi;
3对称性
x1 = [1 9 9 9 0 5 2 5];
N = length(x1);
n_axis = [0:N-1];
x1N = zeros( 1,N );
x1N(0+1) = x1(0+1);
for num=0:N-1
if N-num==N
index = 1;
else
index = (N-num) + 1;
end
x1N( num+1 ) = x1(index);
end
x1_e = 1/2*( x1 + x1N );
x1_o = 1/2*( x1 - x1N );
%-------------------------------------------------------------------
% 1 画出原始序列,原始序列构造的共轭对称、共轭反对称序列
figure(1);
subplot( 3,1,1 );
stem( n_axis, x1,'.' );
title( ['原序列'] );
subplot( 3,1,2 );
stem( n_axis, x1_e,'.' );
title( '共轭对称部分' );
subplot( 3,1,3 );
stem( n_axis, x1_o ,'.');
title( '共轭反对称部分' );
%-------------------------------------------------------------------
% 2 画出奇、偶对称序列的频谱的实部虚部 验证奇对称序列频谱只有虚部,而偶对称序列频谱只有实部
k_axis = n_axis;
fft_x1_e = fft( x1_e );
fft_x1_o = fft( x1_o );
figure(2);
subplot(2,2,1);
stem( k_axis, real(fft_x1_e),'.' );
title( '偶对称序列实部' );
subplot(2,2,3);
stem( k_axis, imag(fft_x1_e),'.' );
title( '偶对称序列虚部' );
subplot(2,2,2);
stem( k_axis, real(fft_x1_o),'.' );
title( '奇对称序列实部' );
subplot(2,2,4);
stem( k_axis, imag(fft_x1_o) ,'.');
title( '奇对称序列虚部' );
%-------------------------------------------------------------------
% 3 当序列为复数时,验证其共轭奇偶对称序列的频谱
J = sqrt(-1);
x1 = [ 1+2*J 3+4*J 5+3*J 3+4*J 6+1*J 8+2*J 3+3*J 9+2*J];
N = length(x1);
n_axis = [0:N-1];
x1N = zeros( 1,N );
x1N(0+1) = x1(0+1);
for num=0:N-1
if N-num==N
index = 1;
else
index = (N-num) + 1;
end
x1N( num+1 ) = x1(index);
end
x1_e = 1/2*( x1 + conj(x1N) ); % 注意,这里加取共轭函数conj
x1_o = 1/2*( x1 - conj(x1N) );
figure(3);
k_axis = n_axis;
fft_x1_e = fft( x1_e );
fft_x1_o = fft( x1_o );
subplot(2,2,1);
stem( k_axis, real(fft_x1_e) );
title( '偶对称序列实部' );
subplot(2,2,3);
stem( k_axis, imag(fft_x1_e) );
title( '偶对称序列虚部' );
subplot(2,2,2);
stem( k_axis, real(fft_x1_o) );
title( '奇对称序列实部' );
subplot(2,2,4);
stem( k_axis, imag(fft_x1_o) );
title( '奇对称序列虚部' );
4频移特性
x1 = [1 9 9 9 0 5 2 5];
fft_x1=fft(x1,8);
fft_x2=circshift(fft_x1,3)
figure
subplot( 2,1,1 );
x_axis=0:1:7
stem( x_axis, abs(fft_x1),'.' ); grid on;
xlabel( '频率 k' ); ylabel( 'f_x1幅度');
title( 'f_x1幅度谱' );
subplot( 2,1,2 );
stem( x_axis, abs(fft_x2),'.' ); grid on;
xlabel( '频率 k' ); ylabel( '频移后幅度');
title( '频移幅度谱' );
figure
x3=ifft(fft_x1)
subplot( 2,2,1 );
stem( x_axis, abs(x3),'.' ); grid on;
ylabel( '时域幅度');
title( '原始序列' );
x4=ifft(fft_x2)
subplot( 2,2, 2);
stem( x_axis, abs(x4),'.' ); grid on;
ylabel( '时域幅度');
title( '频移后时域序列' );
subplot( 2,2, 3);
stem( x_axis, angle(x3), '.' );
title( '原序列相位谱' );
subplot( 2,2, 4);
stem( x_axis, angle(x4), '.' );
title( '频移后相位谱' );
5直流信号的fft和正弦信号的fft
y=ones(1,128)
figure
subplot(2,1,1)
fft_y=fft(y,128);
x_axis=1:1:128
stem(x_axis,abs(fft_y),'.')
title('直流信号FFT幅度谱')
subplot(2,1,2)
stem(x_axis,angle(fft_y),'.')
title('直流信号FFT相位谱')
figure
for n=1:1:128
m(n)=sin(2*pi/64*n)
end
stem(x_axis,m,'.')
figure
fft_m=fft(m,128);
subplot(2,1,1)
stem(x_axis,abs(fft_m),'.')
title('正弦信号FFT幅度谱')
subplot(2,1,2)
stem(x_axis,angle(fft_y),'.')
title('正弦信号FFT相位谱')