|
EDA365欢迎您登录!
您需要 登录 才可以下载或查看,没有帐号?注册
x
' E; s2 Z+ a; t- N, J/ _# x上篇我们讨论了:MATLAB ------- 用 MATLAB 得到高密度谱和高分辨率谱的方式比对(附MATLAB脚本)
, L) v- `( X) S! b
|3 A" i- ~4 D* F7 \可是还是觉得不过瘾,还有下面的情况需要比对。于是就有了这篇。
3 W3 W! O; h; u
$ b* S( ?6 ?& p+ { h5 h案例:
* L: g$ {( A. K6 v" Q8 C9 @" @5 Q4 _' m- Q" T/ o
' D+ }: `% `! x; n& G6 K5 a2 q$ g. g R- D9 h0 m. O% F) j( d
想要基于有限样本数来确定他的频谱。
, c% W+ }; J# t2 |4 i, b. i, X8 v% Y! K/ Z" s# h
下面我们分如下几种情况来分别讨论:
. w% a, \& U4 |+ ?% p. I S5 J7 p" P8 T: K
a. 求出并画出
的DTFT;
& `& G2 [9 M- `+ m7 u) c$ W9 n) k( U: n8 C) G
b. 求出并画出
的DTFT;
0 P! w1 U: ^( p _) G4 d' g4 K0 g( d t' E) \
- 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
- # _$ d* X4 c: I1 J5 ?
/ c! C+ k1 [ u/ I* [- [0 ]$ ?0 J4 S. T
* E) e" B5 m: I* K/ T$ u- j
: k# S$ k1 N# g j5 _6 T可见,b问这种情况,拥有x(n)的更多数据,所以得到的DTFT更加的准确,正如我们所料,频谱在w = 0.48pi以及0.52pi处取得峰值。而a问中的图就看不出这种关系,因为获得序列数据太少,已经严重影响到了频谱的形状。" ~/ ?& V5 `, w: V7 t& B
7 i0 I6 p& @! C6 b- _
Q( b6 n# b! z; D
7 P: _4 y+ v6 r% K+ ?* Y2 h: `
3 ?% m+ `+ k7 Y8 a* T/ U$ J0 c: ?! y) A9 T/ Z
8 I3 j3 x% C! P" S/ C
|
|