Matlab对465KHz的AM信号进行采样和正交解调代码
时间: 2024-05-20 13:15:53 浏览: 182
以下是对465KHz的AM信号进行采样和正交解调的Matlab代码:
% 设置采样频率为1MHz,采样时长为1ms
fs = 1e6;
duration = 1e-3;
% 生成时间序列
t = linspace(0, duration, fs*duration);
% 生成载波信号
fc = 465e3;
carrier = cos(2*pi*fc*t);
% 生成调制信号(假设为1kHz正弦波)
fm = 1e3;
modulation = sin(2*pi*fm*t);
% 生成AM信号
amplitude_modulated = (1 + modulation).*carrier;
% 进行采样
sampling_frequency = 2*fc; % 根据奈奎斯特采样定理,采样频率应至少为2倍的信号最高频率
sampled_signal = amplitude_modulated(1:sampling_frequency/fs:end); % 按照采样频率进行采样
% 进行正交解调
demodulated_I = sampled_signal.*cos(2*pi*fc*t(1:length(sampled_signal)));
demodulated_Q = sampled_signal.*sin(2*pi*fc*t(1:length(sampled_signal)));
% 对解调信号进行低通滤波,提取调制信号
[b, a] = butter(10, fm/(fs/2)); % 10阶巴特沃斯低通滤波器
demodulated_I_filtered = filter(b, a, demodulated_I);
demodulated_Q_filtered = filter(b, a, demodulated_Q);
% 取两路解调信号的幅值差,得到调制信号
demodulated_signal = abs(demodulated_I_filtered - 1i*demodulated_Q_filtered);
% 画出原始信号和解调信号的时域波形
figure;
subplot(2,1,1);
plot(t, amplitude_modulated);
xlabel('Time (s)');
ylabel('Amplitude');
title('AM Signal');
subplot(2,1,2);
plot(t(1:length(sampled_signal)), demodulated_signal);
xlabel('Time (s)');
ylabel('Amplitude');
title('Demodulated Signal');
阅读全文