📅  最后修改于: 2023-12-03 15:26:51.297000             🧑  作者: Mango
本项目是一个基于Simulink的FM调制与解调的仿真程序。该程序旨在演示一种基本的FM调制和解调技术,并可用作教学示例。
% 预设参数
fs = 44100; % 采样率
t = 0:1/fs:1; % 时间向量
f_c = 2000; % 载波频率
f_m = 100; % 原始音频信号频率
A_m = 1; % 原始音频信号幅度
% 原始音频信号
m_t = A_m*sin(2*pi*f_m*t);
% FM调制信号
k_f = 10; % 调制指数
s_f = cos(2*pi*f_c*t + 2*pi*k_f*cumsum(m_t));
% FM解调信号
s_demod = fm_demod(s_f,f_c);
% 绘制波形图
figure
subplot(3,1,1)
plot(t,m_t)
title('Original Audio Signal')
xlabel('Time (s)')
ylabel('Amplitude')
subplot(3,1,2)
plot(t,s_f)
title('FM Modulated Signal')
xlabel('Time (s)')
ylabel('Amplitude')
subplot(3,1,3)
plot(t,s_demod)
title('Demodulated Signal')
xlabel('Time (s)')
ylabel('Amplitude')
function y = fm_demod(x,fc)
% 包络检测
env = abs(hilbert(x));
% 估计包络峰值
env_mean = movmean(env,ceil(0.1*length(env)));
% 自适应门限控制器
T = mean(env_mean);
k = 0.1;
for n=1:length(env_mean)
if env_mean(n) > T
T = (1-k)*T+k*env_mean(n);
else
T = T;
end
z(n) = env(n) - T;
end
% 环路滤波器
omega_0 = 2*pi*fc;
K_0 = 2*pi*0.01*fc;
y = zeros(size(x));
e_i = 0;
e_q = 0;
for n=1:length(x)
omega_i = omega_0 + K_0*z(n)*e_q;
omega_q = omega_0 + K_0*z(n)*e_i;
e_i = sin(omega_i);
e_q = cos(omega_q);
y(n) = 2*(e_i*x(n)-e_q*imag(hilbert(x(n))));
end
end