matlab对信号进行AM调制与解调(仿真)

用matlab仿真AM模拟调制、解调过程

AM调制与解调过程

%AM调制信号的MATLAB实现
dt=0.001; %时间采样频谱
Fs=100;
fm=1; %信源的最高频率
fc=10; %载波中心频率
T=4; %信号时长
N=T/dt; %采样点个数
t=[0:N-1] * dt; %采样点的时间序列
wc=2pifc;

mt=cos(2pit); %信源
figure(1);
subplot(311);
plot(t,mt);
title(‘基带调制信号’);
axis([0 4 -4 4]);
line([0,4],[0,0],‘color’,‘k’);
%mt的最大值是1
A=2;
Fc=A.* cos(wc * t);

sam=(A+mt). * cos(wc*t);
subplot(312);
plot(t,Fc);
title(‘载波信号’);
axis([0 4 -4 4]);
line([0,4],[0,0],‘color’,‘k’);

subplot(313);
plot(t,sam);
hold on; %画出AM信号波形
plot(t,A+mt,‘r–’);
title(‘AM调制信号及其包络 A=2’);
axis([0 4 -4 4]);
line([0,4],[0,0],‘color’,‘k’);

%相干解调
figure(2);
subplot(311);
st=sam.* cos(wc*t);
plot(t,st);
title(‘调制信号与载波信号相乘’);
axis([0 4 -4 4]);
line([0,4],[0,0],‘color’,‘k’);

[f,sf]=T2F(t,st);%傅里叶变换
[t,st]=lpf(f,sf,2 * fm);%低通滤波
subplot(212)
plot(t,st);
title(‘经过低通滤波的相干解调信号波形’);
axis([0 4 -4 4]);
line([0,4],[0,0],‘color’,‘k’);

子函数程序 T2F

function [f,sf]= T2F(t,st)
% dt = t(2)-t(1);
T=t(end);
df = 1/T;
N = length(st);
f=-N/2*df : df : N/2 * df-df;
sf = fft(st);
sf = T/N * fftshift(sf);

子函数程序 F2T

function[t,st]=F2T(f,Sf)
df=f(2)-f(1);
fmax=(f(end)-f(1)+df);
dt=1/fmax;
N=length(f);
t=[0:N-1] * dt;
Sf=fftshift(Sf);
st=fmax * ifft(Sf);
st=real(st);

子函数程序 lpf

function[t,st]=lpf(f,sf,B)
df=f(2)-f(1);
fN=length(f);
ym=zeros(1,fN);
xm=floor(B/df);
xm_shift=[-xm:xm-1]+floor(fN/2);
ym(xm_shift)=1;
yf=ym.* sf;
[t,st]=F2T(f,yf);

结果如下所示

matlab对信号进行AM调制与解调(仿真)matlab对信号进行AM调制与解调(仿真)