❶ 统计信号处理基础怎么用matlab实现

在命令窗口中执行
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