2ASK在matlab下的仿真如下:
clear all
close all
i=10;
j=5000;
t=linspace(0,5,j);%取0,0.001,0.002,。。。5 共5001个点
fc=10;
fm=i/5;
B=2*fc; %产生基带信号
a=round(rand(1,i));%随机序列
figure(2)
plot(rand(1,i))
st=t;
for n=1:10
if a(n)<1;
for m=j/i*(n-1)+1:j/i*n %一个信号取500个点
st(m)=0;
end
else
for m=j/i*(n-1)+1:j/i*n
st(m)=1;
end
end
end
figure(1);
subplot(421);
plot(t,st);
axis([0,5,-1,2]);
title('基带信号');
s1=cos(2*pi*fc*t); %载波
subplot(422);
plot(s1);
title('载波信号');
e_2ask=st.*s1; %调制
subplot(423);
plot(t,e_2ask);
title('已调信号');
noise =rand(1,j);
e_2ask=e_2ask+noise;%加入噪声
subplot(424);
plot(t,e_2ask);
title('加入噪声的信号');
at=e_2ask.*cos(2*pi*fc*t); %相干解调
at=at-mean(at);
subplot(425);
plot(t,at);
title('相乘后信号');
[f,af] = T2F(t,at);%通过低通滤波器
[t,at] = lpf(f,af,2*fm);
subplot(426);
plot(t,at);
title('解调后波形');
for m=0:i-1; %抽样判决
if at(1,m*500+250)+0.5<0.5;
for j=m*500+1:(m+1)*500;
at(1,j)=0;
end
else
for j=m*500+1:(m+1)*500;
at(1,j)=1;
end
end
end
subplot(427);
plot(t,at);
axis([0,5,-1,2]);
title('抽样判决后波形')