• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

【 MATLAB 】使用 MATLAB 得到高密度谱(补零得到DFT)和高分辨率谱(获得更多的数据 ...

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

上篇博文分析了同一有限长序列在不同的N下的DFT之间的不同: MATLAB 】使用 MATLAB 作图讨论有限长序列的 N 点 DFT(强烈推荐)(含MATLAB脚本)

那篇博文中,我们通过补零的方式来增加N,这样最后的结论是随着N的不断增大,我们只会得到DTFT上的更多的采样点,也就是说频率采样率增加了。通过补零,得到高密度谱(DFT),但不能得到高分辨率谱,因为补零并没有任何新的信息附加到这个信号上,要想得到高分辨率谱,我们就得通过获得更多的数据来进行求解DFT。

这篇博文就是为此而写。

案例:

想要基于有限样本数来确定他的频谱。

下面我们分如下几种情况来分别讨论:

a. 求出并画出  ,N = 10 的DFT以及DTFT;

b. 对上一问的x(n)通过补零的方式获得区间[0,99]上的x(n),画出 N = 100点的DFT,并画出DTFT作为对比;

c.求出并画出  ,N = 100 的DFT以及DTFT;

d.对c问中的x(n)补零到N = 500,画出 N = 500点的DFT,并画出DTFT作为对比;

e. 比较c和d这两个序列的序列的DFT以及DTFT的异同。


那就干呗!

题解:

a.

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,1,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,1,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


b.

clc;clear;close all;

n = 0:99;
x = cos(0.48*pi*n) + cos(0.52*pi*n);

% zero padding into N = 100
n1 = 0:99;
y1 = [x(1:10),zeros(1,90)];

subplot(2,1,1)
stem(n1,y1);
title('signal x(n), 0 <= n <= 99');
xlabel('n');ylabel('x(n) over n in [0,99]');
Y1 = dft(y1,100);
magY1 = abs(Y1);
k1 = 0:1:99;
N = 100;
w1 = (2*pi/N)*k1;
subplot(2,1,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);
% w = [-fliplr(w),w(2:K+1)];   %plot DTFT in [-pi,pi]
% X = [fliplr(X),X(2:K+1)];    %plot DTFT in [-pi,pi]
magX = abs(X);
% angX = angle(X)*180/pi;
% figure
% subplot(2,1,1);
hold on 
plot(w/pi,magX);
% title('Discrete-time Fourier Transform in Magnitude Part');
% xlabel('w in pi units');ylabel('Magnitude of X');
% subplot(2,1,2);
% plot(w/pi,angX);
% title('Discrete-time Fourier Transform in Phase Part');
% xlabel('w in pi units');ylabel('Phase of X ');
hold off


 

c.

clc;clear;close all;

n = 0:99;
x = cos(0.48*pi*n) + cos(0.52*pi*n);

% n1 = 0:99;
% y1 = [x(1:10),zeros(1,90)];

subplot(2,1,1)
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,1,2);
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);
% w = [-fliplr(w),w(2:K+1)];   %plot DTFT in [-pi,pi]
% X = [fliplr(X),X(2:K+1)];    %plot DTFT in [-pi,pi]
magX = abs(X);
% angX = angle(X)*180/pi;
% figure
% subplot(2,1,1);
hold on 
plot(w/pi,magX);
% title('Discrete-time Fourier Transform in Magnitude Part');
% xlabel('w in pi units');ylabel('Magnitude of X');
% subplot(2,1,2);
% plot(w/pi,angX);
% title('Discrete-time Fourier Transform in Phase Part');
% xlabel('w in pi units');ylabel('Phase of X ');
hold off


太小了,放大看:

 

d.

clc;clear;close all;

n = 0:99;
x = cos(0.48*pi*n) + cos(0.52*pi*n);

% n1 = 0:99;
% y1 = [x(1:10),zeros(1,90)];

%zero padding into N = 500
n1 = 0:499;
x1 = [x,zeros(1,400)];

subplot(2,1,1)
stem(n1,x1);
title('signal x(n), 0 <= n <= 499');
xlabel('n');ylabel('x(n) over n in [0,499]');
Xk = dft(x1,500);
magXk = abs(Xk);
k1 = 0:1:499;
N = 500;
w1 = (2*pi/N)*k1;
subplot(2,1,2);
% stem(w1/pi,magXk);
stem(w1/pi,magXk);
title('DFT of x(n) in [0,499]');
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 = x1*exp(-j*n1'*w);
% w = [-fliplr(w),w(2:K+1)];   %plot DTFT in [-pi,pi]
% X = [fliplr(X),X(2:K+1)];    %plot DTFT in [-pi,pi]
magX = abs(X);
% angX = angle(X)*180/pi;
% figure
% subplot(2,1,1);
hold on 
plot(w/pi,magX,'r');
% title('Discrete-time Fourier Transform in Magnitude Part');
% xlabel('w in pi units');ylabel('Magnitude of X');
% subplot(2,1,2);
% plot(w/pi,angX);
% title('Discrete-time Fourier Transform in Phase Part');
% xlabel('w in pi units');ylabel('Phase of X ');
hold off


 

e.

clc;clear;close all;

n = 0:99;
x = cos(0.48*pi*n) + cos(0.52*pi*n);

subplot(2,1,1)
% 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;
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);
% w = [-fliplr(w),w(2:K+1)];   %plot DTFT in [-pi,pi]
% X = [fliplr(X),X(2:K+1)];    %plot DTFT in [-pi,pi]
magX = abs(X);
% angX = angle(X)*180/pi;
% figure
% subplot(2,1,1);
hold on 
plot(w/pi,magX);
% title('Discrete-time Fourier Transform in Magnitude Part');
% xlabel('w in pi units');ylabel('Magnitude of X');
% subplot(2,1,2);
% plot(w/pi,angX);
% title('Discrete-time Fourier Transform in Phase Part');
% xlabel('w in pi units');ylabel('Phase of X ');
hold off





% clc;clear;close all;
% 
% n = 0:99;
% x = cos(0.48*pi*n) + cos(0.52*pi*n);

% n1 = 0:99;
% y1 = [x(1:10),zeros(1,90)];

%zero padding into N = 500
n1 = 0:499;
x1 = [x,zeros(1,400)];
subplot(2,1,2);
% subplot(2,1,1)
% stem(n1,x1);
% title('signal x(n), 0 <= n <= 499');
% xlabel('n');ylabel('x(n) over n in [0,499]');
Xk = dft(x1,500);
magXk = abs(Xk);
k1 = 0:1:499;
N = 500;
w1 = (2*pi/N)*k1;

stem(w1/pi,magXk);
title('DFT of x(n) in [0,499]');
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 = x1*exp(-j*n1'*w);
% w = [-fliplr(w),w(2:K+1)];   %plot DTFT in [-pi,pi]
% X = [fliplr(X),X(2:K+1)];    %plot DTFT in [-pi,pi]
magX = abs(X);
% angX = angle(X)*180/pi;
% figure
% subplot(2,1,1);
hold on 
plot(w/pi,magX,'r');
% title('Discrete-time Fourier Transform in Magnitude Part');
% xlabel('w in pi units');ylabel('Magnitude of X');
% subplot(2,1,2);
% plot(w/pi,angX);
% title('Discrete-time Fourier Transform in Phase Part');
% xlabel('w in pi units');ylabel('Phase of X ');
hold off

局部放大看:

 

 

 

 


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap