⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sawtoohfft2.m

📁 使用FFT分析三角波信号的频谱,讨论采样点数、采样频率对谱分辨率的影响。
💻 M
字号:

Fs=618;
N=310;
n=0:N-1;
t=n/Fs;

x=sawtooth(2*pi*200*t,0.5)+sawtooth(2*pi*202*t,0.5)+sawtooth(2*pi*206*t,0.5);
y=sawtooth(2*pi*200*t,0.5)+sawtooth(2*pi*202*t,0.5)+sawtooth(2*pi*206*t,0.5)+randn(1,length(t));
%信号最高频率f0=206hz,频率分辨率F=2hz
%tp=0.5;
%T取样周期T《=1/2*f0
%N 》=2*f0/F=206

fx=fft(y);
%N个点有N-1个间隔;


ff=(0:N/2-1)*Fs/N;
f=(0:length(fx)-1)'*Fs/length(fx);%进行对应的频率转换
subplot(411);
plot(t,y);grid; title('受噪声干扰三角波信号');
subplot(412);
plot(f(1:N/2),abs(fx(1:N/2))); grid;title('受噪声干扰,取样点310,采样率为618hz');axis([0,250,0,300]);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Fs=1236;
N=310;
n=0:N-1;
t=n/Fs;
x=sawtooth(2*pi*200*t,0.5)+sawtooth(2*pi*202*t,0.5)+sawtooth(2*pi*206*t,0.5);
y=sawtooth(2*pi*200*t,0.5)+sawtooth(2*pi*202*t,0.5)+sawtooth(2*pi*206*t,0.5)+randn(1,length(t));
%信号最高频率f0=206hz,频率分辨率F=2hz
%tp=0.5;
%T取样周期T《=1/2*f0
%N 》=2*f0/F=206

fx=fft(y);
%N个点有N-1个间隔;



ff=(0:N/2-1)*Fs/N;
subplot(413);
f=(0:length(fx)-1)'*Fs/length(fx);%进行对应的频率转换

plot(f(1:N/2),abs(fx(1:N/2))); grid;title('受噪声干扰,取样点310,采样率为1236hz');axis([0,250,0,300]);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Fs=618;
N=600
n=0:N-1;
t=n/Fs;

x=sawtooth(2*pi*200*t,0.5)+sawtooth(2*pi*202*t,0.5)+sawtooth(2*pi*206*t,0.5);
y=sawtooth(2*pi*200*t,0.5)+sawtooth(2*pi*202*t,0.5)+sawtooth(2*pi*206*t,0.5)+randn(1,length(t));

%信号最高频率f0=206hz,频率分辨率F=2hz
%tp=0.5;
%T取样周期T《=1/2*f0
%N 》=2*f0/F=206

fx=fft(y);
%N个点有N-1个间隔;

f=(0:length(fx)-1)'*Fs/length(fx);%进行对应的频率转换
ff=(0:N/2-1)*Fs/N;
subplot(414);
plot(f(1:N/2),abs(fx(1:N/2))); grid;title('受噪声干扰,增加取样点600,采样率为618hz');axis([0,250,0,300]);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -