|
|
EDA365欢迎您登录!
您需要 登录 才可以下载或查看,没有帐号?注册
x
0 G# _4 X' ~/ Z上篇我们讨论了:MATLAB ------- 用 MATLAB 得到高密度谱和高分辨率谱的方式比对(附MATLAB脚本)
) h0 I4 T' g! [- O9 C3 x2 M2 I( U5 h
可是还是觉得不过瘾,还有下面的情况需要比对。于是就有了这篇。1 t4 v9 H8 h3 K: ?! H) o/ m& e
% y0 N" _4 G1 h- A案例:
s: O6 i o1 h3 e
( l9 `# ~! _& O. X1 E( e
- b* y3 \ M6 j7 h% {+ ]
; P' G# ?( Y. m# [想要基于有限样本数来确定他的频谱。4 G7 j* J' b6 L5 |+ _! ]
) Q7 X% P" z+ w6 [; g$ S1 _下面我们分如下几种情况来分别讨论:6 Z$ l7 q4 z+ Y: C2 ~* t
+ K* Q8 |7 a- t/ F$ _' t
a. 求出并画出
的DTFT;
( @& q6 y+ u, T7 L' p
& }, a7 Z$ s; W# kb. 求出并画出
的DTFT;
+ y9 C) ^0 }) L3 O
; w0 F% G# f9 G, j3 W! S- clc;clear;close all;
- n = 0:99;
- x = cos(0.48*pi*n) + cos(0.52*pi*n);
- n1 = 0:9;
- y1 = x(1:10);
- subplot(2,2,1)
- stem(n1,y1);
- title('signal x(n), 0 <= n <= 9');
- xlabel('n');ylabel('x(n) over n in [0,9]');
- Y1 = dft(y1,10);
- magY1 = abs(Y1);
- k1 = 0:1:9;
- N = 10;
- w1 = (2*pi/N)*k1;
- subplot(2,2,2);
- % stem(w1/pi,magY1);
- % title('DFT of x(n) in [0,9]');
- % xlabel('frequency in pi units');
- %In order to clearly see the relationship between DTFT and DFT, we draw DTFT on the same picture.
- %Discrete-time Fourier Transform
- K = 500;
- k = 0:1:K;
- w = 2*pi*k/K; %plot DTFT in [0,2pi];
- X = y1*exp(-j*n1'*w);
- magX = abs(X);
- % hold on
- plot(w/pi,magX);
- % hold off
- subplot(2,2,3)
- stem(n,x);
- title('signal x(n), 0 <= n <= 99');
- xlabel('n');ylabel('x(n) over n in [0,99]');
- Xk = dft(x,100);
- magXk = abs(Xk);
- k1 = 0:1:99;
- N = 100;
- w1 = (2*pi/N)*k1;
- subplot(2,2,4);
- % stem(w1/pi,magXk);
- % title('DFT of x(n) in [0,99]');
- % xlabel('frequency in pi units');
- %In order to clearly see the relationship between DTFT and DFT, we draw DTFT on the same picture.
- %Discrete-time Fourier Transform
- K = 500;
- k = 0:1:K;
- w = 2*pi*k/K; %plot DTFT in [0,2pi];
- X = x*exp(-j*n'*w);
- magX = abs(X);
- hold on
- plot(w/pi,magX);
- hold off
- 1 ~( {( P+ r7 i5 |* z$ D& F
* ?& O4 P" z% `9 f# r) @
R9 `9 u% V7 }4 L: h3 ^
8 U. r5 ]; v9 M' r
7 X/ A# A3 C- t* U) g5 o4 p可见,b问这种情况,拥有x(n)的更多数据,所以得到的DTFT更加的准确,正如我们所料,频谱在w = 0.48pi以及0.52pi处取得峰值。而a问中的图就看不出这种关系,因为获得序列数据太少,已经严重影响到了频谱的形状。
7 L% \' V( [$ i- }
. B9 f. L+ q/ }. n5 P$ o4 G+ N* h0 f6 e; H
4 H+ S: z, V% `' J) k9 i
' V5 |; ]; B3 `! ?
$ ?2 F& ]7 O9 c/ ~) G( m9 N, r5 I3 o( p4 q3 x! V( ?
|
|