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

📄 ch3example14prg1.m

📁 通信程序源代码和模型通信程序源代码和模型通信程序源代码和模型
💻 M
字号:
% ch3example14prg1.m
fs=200;                           % 采样率
Delta_f = 1;                      % 频率分辨率
T = 1/fs;                         % 时间分辨率
L=1/ Delta_f;                     % 时域截取长度
N= floor(fs/Delta_f)+1;           % 计算截断信号的采样点数
t=0:T:L;                          % 截取时间段和采样时间点
freq=0: Delta_f :fs;              % 分析的频率范围和频率分辨率
f_t =(sin(2*pi*50*t)+0.7*sin(2*pi*75*t))'; 
% 在截取范围内的分析的信号时域波形
f_t_rectwin= rectwin(N).*f_t./sqrt(sum(abs(rectwin(N).^2))./N); 
% 矩形窗(功率归一化)
f_t_hamming= hamming(N) .*f_t./sqrt(sum(abs(hamming(N).^2))./N);
% 海明窗(功率归一化)
f_t_hann = hann(N) .*f_t./sqrt(sum(abs(hann(N).^2))./N);        
% 汉宁窗(功率归一化)

F_w_rectwin =T.* fft(f_t_rectwin, N);
% 进行N点FFT,并乘以采样时间间隔T得到频谱
F_w_hamming =T.* fft(f_t_hamming, N);      % 加海明窗的频谱
F_w_hann =T.* fft(f_t_hann, N);            % 加汉宁窗的频谱figure(1);
subplot(2,2,1);plot(t,f_t);title('Original Signal');
subplot(2,2,2);plot(t, f_t_rectwin);title('Rectwin Windowing');
subplot(2,2,3);plot(t, f_t_hamming);title('hamming Windowing');
subplot(2,2,4);plot(t, f_t_hann);title('hanning Windowing');

figure(2);
subplot(3,1,1);plot(freq, 10*log10(abs(F_w_rectwin)));
title('Rectwin Windowing Spectrum');ylabel('幅度 dB');
axis([0,200,-50,0]);grid on;
subplot(3,1,2);plot(freq, 10*log10(abs(F_w_hamming)));
title('hamming Windowing Spectrum');ylabel('幅度 dB');
axis([0,200,-50,0]);grid on;
subplot(3,1,3);plot(freq, 10*log10(abs(F_w_hann)));
title('hanning Windowing Spectrum');ylabel('幅度 dB');
axis([0,200,-50,0]);grid on;
p_original_signal=var(f_t)   % 计算原始信号的平均功率
p_hannwindowed=sum((abs(F_w_hann/T)).^2)/(N^2) % 计算加窗后的信号功率

⌨️ 快捷键说明

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