作业帮 > 综合 > 作业

信号分析与处理,用matlab怎么实现?

来源:学生作业帮 编辑:作业帮 分类:综合作业 时间:2024/10/06 09:20:20
信号分析与处理,用matlab怎么实现?
已知信号,其中、、,采用采样频率为进行采样,求:
(1)当采样长度分别为512和2048情况下的幅度频谱.
(2)当采样长度为32,且增补个零点,4个个零点、8个零点、16个零点情况下的幅度频谱.
我把刚才那位网友的程序改了一下,不是因为他的程序不对,而是补充了你的第二问.有一点需要说明,要想把4Hz和4.02Hz的两个频率分开,作FFT的点数至少为2000点,这点你可以在执行完程序后,在命令窗口中执行
figure(1)
subplot(212)
axis([3.5 5.5 0 1200])
能看到结果
修改后代码如下
close all
clear all
clc
f1=4;
f2=4.02;
f3=5;
fs=20;
ts=1/fs;
N1=512;
T=N1*ts;
t=0:ts:T-ts;
x=sin(2*pi*f1*t)+sin(2*pi*f2*t)+sin(2*pi*f3*t);
xf=fft(x,N1);
f=(0:N1/2-1)/N1*fs;
figure(1)
subplot(211)
plot(f,abs(xf(1:N1/2)))
N2=2048;
T=N2*ts;
t=0:ts:T-ts;
x=sin(2*pi*f1*t)+sin(2*pi*f2*t)+sin(2*pi*f3*t);
xf=fft(x,N2);
f=(0:N2/2-1)/N2*fs;
subplot(212)
plot(f,abs(xf(1:N2/2)))
N=32;
T=N*ts;
t=0:ts:T-ts;
x=sin(2*pi*f1*t)+sin(2*pi*f2*t)+sin(2*pi*f3*t);
figure(2)
subplot(221)
N3=(1+1)*N;
clear xf
xf=fft(x,N3);
f=(0:N3/2-1)/N3*fs;
plot(f,abs(xf(1:N3/2)))
grid
subplot(222)
N4=(4+1)*N;
clear xf
xf=fft(x,N4);
f=(0:N4/2-1)/N4*fs;
plot(f,abs(xf(1:N4/2)))
grid
subplot(223)
N5=(8+1)*N;
clear xf
xf=fft(x,N5);
f=(0:N5/2-1)/N5*fs;
plot(f,abs(xf(1:N5/2)))
grid
subplot(224)
N6=(16+1)*N;
clear xf
xf=fft(x,N6);
f=(0:N6/2-1)/N6*fs;
plot(f,abs(xf(1:N6/2)))
grid