信号的实验matlab.docx
- 文档编号:16370926
- 上传时间:2023-07-12
- 格式:DOCX
- 页数:23
- 大小:227.74KB
信号的实验matlab.docx
《信号的实验matlab.docx》由会员分享,可在线阅读,更多相关《信号的实验matlab.docx(23页珍藏版)》请在冰点文库上搜索。
信号的实验matlab
1、x1(n)=R4(n)
clearall
x1=[1111zeros(1,4)];
N=8;
X1=fft(x1,N);
subplot(1,3,1);stem(x1);
title('原信号');gridon;
subplot(1,3,2);stem(abs(X1));
title('幅频');gridon;
subplot(1,3,3);stem(angle(X1));
title('相频');gridon;
2、
clearall
n=1:
4;
x2(n)=n+1;
n=5:
8;
x2(n)=8-n;
y=fft(x2,8);
subplot(2,2,1);stem(x2);
title('原信号');gridon;
subplot(2,2,3);stem(abs(y));
title('幅频');gridon;
subplot(2,2,4);stem(angle(y));
title('相频');gridon;
3、
clearall
n=1:
4;
x3(n)=4-n;
n=5:
8;
x3(n)=n-3;
y=fft(x3,8);
subplot(2,2,1);stem(x3);
title('ÔÐźÅ');gridon;
subplot(2,2,3);stem(abs(y));
title('·ùƵ');gridon;
subplot(2,2,4);stem(angle(y));
title('ÏàƵ');gridon;
clearall
n=0:
pi/10:
8;
N=8;
x4=cos(pi/4*n);
X4=fft(x4,N);
subplot(2,2,1);stem(n,x4);
xlabel('时间/s');ylabel('x4(n)');
title('原信号');
subplot(2,2,3);stem(abs(X4));
xlabel('弧度');ylabel('幅度');
title('幅频');
subplot(2,2,4);stem(angle(X4));
title('相频');
xlabel('弧度');ylabel('幅度');
5、
clearall
n=0:
pi/10:
8;
N=8;
x4=sin(pi/4*n);
X4=fft(x4,N);
subplot(2,2,1);stem(n,x4);
xlabel('时间/s');ylabel('x4(n)');
title('原信号');
subplot(2,2,3);stem(abs(X4));
xlabel('弧度');ylabel('幅度');
title('幅频');
subplot(2,2,4);stem(angle(X4));
title('相频');
xlabel('弧度');ylabel('幅度');
6、
clearall
fs=64;N=8;
n=0:
1:
N-1;t=n/fs;
x6=cos(8*pi*t)+cos(16*pi*t)+cos(20*pi*t);
X6=fft(x6,N);
subplot(2,2,1);plot(t,x6);
xlabel('时间/s');ylabel('x6');
title('原始信号');
gridon;
subplot(2,2,2);stem(n,abs(X6));
xlabel('频率');ylabel('幅度');
title('幅频');
gridon;
subplot(2,2,3);stem(n,angle(X6));
xlabel('频率');ylabel('幅度');
title('相频');
gridon;
7、
clearall
N=8;
n=0:
1:
N-1;
x4=cos(pi/4*n);x5=sin(pi/4*n);
x7=x4+x5;
X7=fft(x7,N);
subplot(1,3,1);stem(n,x7);
xlabel('ʱ¼ä/s');ylabel('x7');
title('ÔʼÐźÅ');
gridon;
subplot(1,3,2);stem(abs(X7));
xlabel('ƵÂÊ');ylabel('·ù¶È');
title('·ùƵ');
gridon;
subplot(1,3,3);stem(angle(X7));
xlabel('ƵÂÊ');ylabel('·ù¶È');
title('ÏàƵ');
gridon;
8、
clearall
N=8;
n=0:
1:
N-1;
x4=cos(pi/4*n);x5=sin(pi/4*n);
x8=x4+i*x5;
X8=fft(x8,N);
subplot(1,3,1);stem(n,x8);
xlabel('时间/s');ylabel('x8');
title('原始信号');
gridon;
subplot(1,3,2);stem(abs(X8));
xlabel('频率');ylabel('幅度');
title('幅频');
gridon;
subplot(1,3,3);stem(angle(X8));
xlabel('频率');ylabel('幅度');
title('相频');
gridon;
(1)N=8时,
和
的幅频特性是否相同?
为什么?
N=16呢?
答:
N=8时相同,可以通过圆周卷积得到;N=16时,也是一样
(2)如果周期信号的周期预先不知道,如何用FFT进行谱分析?
答:
先取N长的序列进行分析,再取2N长的序列分析,两者做差,如果误差较大的话,再取4N长序列分析,依次下去,知道两者近似相同。
实验二频谱细化、频谱泄漏及栅栏效应
1、
N=8、16、32
clearall
n=1:
4;
x2(n)=n+1;
n=5:
8;
x2(n)=8-n;
y=fft(x2,8);
subplot(1,3,1);stem(x2);
title('原信号');gridon;
subplot(1,3,2);stem(abs(y));
title('幅频');gridon;
subplot(1,3,3);stem(angle(y));
title('相频');gridon;
2、
N=8、16、32
clearall
n=0:
pi/10:
8;
N=16;
x4=cos(pi/4*n);
X4=fft(x4,N);
subplot(1,3,1);stem(n,x4);
xlabel('时间/s');ylabel('x4(n)');
title('原信号');
subplot(1,3,3);stem(abs(X4));
xlabel('弧度');ylabel('幅度');
title('幅频');
subplot(1,3,2);stem(angle(X4));
title('相频');
xlabel('弧度');ylabel('幅度');
3、
N=16、32
clearall
fs=64;N=16;
n=0:
1:
N-1;t=n/fs;
x6=cos(8*pi*t)+cos(16*pi*t)+cos(20*pi*t);
X6=fft(x6,N);
subplot(2,2,1);plot(t,x6);
xlabel('时间/s');ylabel('x6');
title('原始信号');
gridon;
subplot(2,2,2);stem(n,abs(X6));
xlabel('频率');ylabel('角度');
title('幅频');
gridon;
subplot(2,2,3);stem(n,angle(X6));
xlabel('频率');ylabel('角度');
title('相频');
gridon;
4、505HZ正弦波,fs=5120HZ,计算点数为512.
clearall
fs=5120;N=512;
n=0:
1:
N-1;t=n/fs;
x6=sin(505*2*pi*t);
X6=fft(x6,N);
plot(t,x6);
xlabel('ʱ¼ä/s');ylabel('x6');
title('ÔʼÐźÅ');
gridon;
figure:
stem(n,abs(X6));
xlabel('ƵÂÊ');ylabel('·ù¶È');
title('·ùƵ');
gridon;
figure:
stem(n,angle(X6));
xlabel('ƵÂÊ');ylabel('·ù¶È');
title('ÏàƵ');
gridon;
5、300hz正弦波,fs=1200hz,N=512.
clearall
fs=1200;N=512;
n=0:
1:
N-1;t=n/fs;
x=sin(300*2*pi*t);
w=rectwin(N);
s=w';
x6=x.*s;
X6=fft(x6,N);
plot(t,x6);
xlabel('ʱ¼ä/s');ylabel('x6');
title('ÔʼÐźÅ');
gridon;
figure:
stem(n,abs(X6));
xlabel('ƵÂÊ');ylabel('·ù¶È');
title('·ùƵ');
gridon;
figure:
stem(n,angle(X6));
xlabel('ƵÂÊ');ylabel('·ù¶È');
title('ÏàƵ');
gridon;
clearall
fs=1200;N=512;
n=0:
1:
N-1;t=n/fs;
x=sin(300*2*pi*t);
w=hann(N);
s=w';
x6=x.*s;
X6=fft(x6,N);
plot(t,x6);
xlabel('ʱ¼ä/s');ylabel('x6');
title('ÔʼÐźÅ');
gridon;
figure:
stem(n,abs(X6));
xlabel('ƵÂÊ');ylabel('·ù¶È');
title('·ùƵ');
gridon;
figure:
stem(n,angle(X6));
xlabel('ƵÂÊ');ylabel('·ù¶È');
title('ÏàƵ');
gridon;
(1)信号整周期采样时,其FFT谱中是否还存在能量泄漏误差?
存在。
取样频率越高能量泄漏越少。
(2)信号整周期采样时,其FFT谱中是否还存在栅栏效应误差?
对信号的频谱进行细化时,对序列进行末尾补零点后,序列的长度必须是原序列长度的整数倍吗?
存在。
取样频率越高栅栏效应误差越小。
必须是。
相当于做内插。
clearall
x1=ones(1,256);
x2=ones(1,128);
y=conv(x1,x2);
stem(y);
title('线性卷积');
clearall
x1=ones(1,256);
x2=ones(1,128);
X1=fft(x1,383);
X2=fft(x2,383);
X=X1.*X2;
y=ifft(X);
stem(abs(y));
title('圆周卷积');
clearall
x1=ones(1,1024);
x2=ones(1,128);
y=conv(x1,x2);
stem(y);
title('线性卷积');
clearall
x1=ones(1,1024)
x2=ones(1,128)
X2=fft(x2,255)
Y=zeros(1,1151)
fori=1:
8
X1=x1(1,128*(i-1)+1:
128*i)
X3=fft(X1,255)
X4=X2.*X3
X5=ifft(X4)
X5=[zeros(1,(i-1)*128)X5zeros(1,1151-(i-1)*128-255)]
Y=Y+X5
end
figure:
stem(abs(Y));
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 信号 实验 matlab
![提示](https://static.bingdoc.com/images/bang_tan.gif)