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

📄 am_module.m

📁 给出调幅信号 的 生成 及 理论 分析 的 仿真程序
💻 M
字号:

%ASK modulation ang demodulation with amplitudes a/4  as 0 ,a as 1;or a/9
%as 0 ,a as 1;
%M-ary
clear all
M=2;%码元调制级别,此为二元
%Amplitude gap
d=1;
%Duration
N=10000;%样点数
%Generate bit sream
a=randint(1,N,2);
%幅度映射,分为三种情况考虑,第一种为0、1映射;第二种为75%调制;第三种为90%调制
for i=1:N
    if a(i)==0;
        a_out(i)=0;
    else
        a_out(i)=1;
    end
end
for i=1:N
    if a(i)==0;
        b_out(i)=1/4;
    else
        b_out(i)=1;
    end
end
for i=1:N
    if a(i)==0;
        c_out(i)=1/9;
    else
        c_out(i)=1;
    end
end
%Generate symbol
s1=a_out;
s2=b_out;
s3=c_out;
%Through AWGN channel
snrindb=1:16;
snr=10.^(snrindb/10);
error_rate1=zeros(1,length(snrindb));
error_rate2=zeros(1,length(snrindb));
error_rate3=zeros(1,length(snrindb));
%Monte Carlo simulation
for i=1:length(snrindb)
 sigma=sqrt(1/(2*snr(i)));
 %加噪声
 r1=s1+sigma*randn(1,N);
 r2=s2+sigma*randn(1,N);
 r3=s3+sigma*randn(1,N);
   for n=1:N
    %Detection,以上三种情况分别依据不同的门限进行判决
     if r1(n)>1/2
        output1(n)=1;
    else
        output1(n)=0;
    end

    if r2(n)>5/8
        output2(n)=1;
    else
        output2(n)=0;
    end

    if r3(n)>5/9
        output3(n)=1;
    else
        output3(n)=0;
    end
   end
  %deciding the error rate
   error1=sum(output1~=a);
   error2=sum(output2~=a);
   error3=sum(output3~=a);
   error_rate1(i)=error1/N;
   error_rate2(i)=error2/N;
   error_rate3(i)=error3/N;
   theory(i)=Qfunct(sqrt(1/2*snr(i)));%理论值
end
%Drawing
semilogy(snrindb,error_rate1,'o');grid on;
hold on;
semilogy(snrindb,error_rate2,':');
semilogy(snrindb,error_rate3);
semilogy(snrindb,theory,'r');
xlabel('snrindb');
ylabel('error_rate');
title(' ASK Monte carlo simulation');

⌨️ 快捷键说明

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