|
|
EDA365欢迎您登录!
您需要 登录 才可以下载或查看,没有帐号?注册
x
9 c- B8 _ f4 F) ?, p% W7 d
上篇我们讨论了:MATLAB ------- 用 MATLAB 得到高密度谱和高分辨率谱的方式比对(附MATLAB脚本)/ G# k O: U9 |1 A
0 @# l. a, O- K- e$ H可是还是觉得不过瘾,还有下面的情况需要比对。于是就有了这篇。3 r+ _: Z- ?) o1 v- b
# _! g; o; Z) u" Q' g. u' b" B
案例:* p+ u/ T% `: A4 R
4 L% Y7 e# M$ W3 U: C8 [% G4 W
0 G. q/ H/ Q9 A1 Q( h& @
8 \! U% k# ], z( ^- F想要基于有限样本数来确定他的频谱。! |) T5 i& o6 [1 U' H
[5 v* \/ E" j, G
下面我们分如下几种情况来分别讨论: G, {+ H" T, | v4 E
0 ]: u7 e5 t0 {2 K9 S) H' Ba. 求出并画出
的DTFT;
4 c' h! ?4 u- f8 S7 `1 U
/ A6 x7 }8 Q% [. o- [6 p% rb. 求出并画出
的DTFT;
e' |; z9 X, L% f/ e9 M7 b) Y
i( Y0 H# m* s: S) T8 a3 l3 f 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
- 0 }+ v0 c6 W7 k
; u/ `: H2 B2 r
1 Y; K; D: a) Z) m7 c9 H5 F' Q
* S9 |: r g. b3 D
5 G3 m7 o- o' q X5 k5 k1 U+ y
可见,b问这种情况,拥有x(n)的更多数据,所以得到的DTFT更加的准确,正如我们所料,频谱在w = 0.48pi以及0.52pi处取得峰值。而a问中的图就看不出这种关系,因为获得序列数据太少,已经严重影响到了频谱的形状。
# B! @ M* x" j- y0 p' f. m6 m5 ^
$ z7 a& L6 {' `( [
1 I. a1 D. P9 K3 Z
* u1 ]' g, S: f' X4 G' F0 A1 ]# H9 T+ \6 M% H5 }! G/ g3 j
8 e' U9 x5 o s1 ~% K
3 q& a. F5 l; O) \
|
|