|
EDA365欢迎您登录!
您需要 登录 才可以下载或查看,没有帐号?注册
x
8 W6 p& H8 N5 W' ]5 c' A9 ~
上篇我们讨论了:MATLAB ------- 用 MATLAB 得到高密度谱和高分辨率谱的方式比对(附MATLAB脚本): }, q3 J+ q- f/ }( C4 F% ?$ X
; z# o _* V3 }5 A) E
可是还是觉得不过瘾,还有下面的情况需要比对。于是就有了这篇。
6 W6 P0 o: B# V$ s9 V. D- Q1 ~, N- |5 j2 r2 a% b
案例:/ i/ G7 `3 U$ A* t6 {% Z5 Q0 |5 }
0 k, Y$ A) g' G+ C9 O9 w
! K, o* R, x9 g# b& B& i# d
3 t" N" E( b' |
想要基于有限样本数来确定他的频谱。/ W- Y" F, z9 N7 q( g
: Y# e2 p0 A: e" i7 R: Q
下面我们分如下几种情况来分别讨论:
s: q& ~2 A3 Q: j2 j0 l' L$ V. y1 r8 S) l {+ p& F, l
a. 求出并画出
的DTFT;5 n) e1 ^3 c9 J; g3 u9 U
5 s) r' \( a; g. [2 u. ob. 求出并画出
的DTFT;
- ^' C7 V6 o7 X) C s& \0 v
; B/ V6 M+ }7 |5 E! C- 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
) B. F- C" w& } , P& `; i5 @/ C, b
. u H& {% `( j6 [7 j
" J4 q9 q% {0 D Z0 j
3 |. V/ u5 X6 o; U! C
可见,b问这种情况,拥有x(n)的更多数据,所以得到的DTFT更加的准确,正如我们所料,频谱在w = 0.48pi以及0.52pi处取得峰值。而a问中的图就看不出这种关系,因为获得序列数据太少,已经严重影响到了频谱的形状。: W. D+ e8 W0 P) Y( J; _; D
6 F" x$ X' H) X7 X( ^/ z9 i
3 ^- ]$ ]- X' Q/ M7 Y
0 B2 D) w6 ^1 a4 C7 s9 ]
5 x' y# A/ U2 _$ a0 M
* V/ b# j" y: L" `, _" Y% n# V1 y B3 ^! L- e
|
|