|
|
EDA365欢迎您登录!
您需要 登录 才可以下载或查看,没有帐号?注册
x
8 L# ~0 L8 L C
上篇我们讨论了:MATLAB ------- 用 MATLAB 得到高密度谱和高分辨率谱的方式比对(附MATLAB脚本)
% z# N. A4 J1 g2 y/ x4 v \3 U1 b$ N; w' ?
可是还是觉得不过瘾,还有下面的情况需要比对。于是就有了这篇。
6 P; t& p$ ?% b. o% z2 @4 Z: U: _: W6 h9 X
案例:
' x4 @/ \, O0 _/ `3 U8 F/ ?& E5 M. e: O( `* B% ~- D; [% m6 [
* x* V+ t. W3 [3 u4 k' A! R5 J# u3 ?! o, H/ d( g# u- M
想要基于有限样本数来确定他的频谱。
! k. W# N+ O0 }0 |7 X: F9 o2 V4 ~6 G- |) C1 @; s) j
下面我们分如下几种情况来分别讨论:; q9 B7 Z+ G8 ]6 H# X
6 t( R: M* u2 K$ m* [3 [
a. 求出并画出
的DTFT;5 }$ R. y, ~ j' V
9 j$ T; N0 H, F) R' q6 W: m1 ^b. 求出并画出
的DTFT;
" A5 k3 s# ^5 e& K3 u5 g/ `. ^
, f( l; n w2 ~9 _8 |# u+ R! N- 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
" Q( D/ m8 L' {7 j# ^; M: G
; l5 ^9 c- }. e6 `1 N6 _# r p
' T5 r6 u6 S$ u* x1 Z a3 x
+ y% I3 Y* Z# ] H7 C( L& P$ F, c* d/ W- l n+ ?
可见,b问这种情况,拥有x(n)的更多数据,所以得到的DTFT更加的准确,正如我们所料,频谱在w = 0.48pi以及0.52pi处取得峰值。而a问中的图就看不出这种关系,因为获得序列数据太少,已经严重影响到了频谱的形状。
5 h3 Q6 C2 h1 V, H2 R
( J8 ^) R% w# ]" S2 \# W
. g) r6 b) o8 W9 ?7 s5 O2 c# b
. Q. E# v7 N% K! W& q) Z
' \/ Z8 T/ n* R7 r$ W2 `# P/ R, S8 n6 Z
( M4 d6 C% k I7 x/ j7 E6 Q
|
|