• 数字调制(ASK、FSK、PSK)


    2ASK(二进制幅移键控)又称OOK

    function askdigital(s,f)
    % 实现ASK调制
    % s——输入二进制序列;f——载波的频率,即:一个码元周期包括f个载波周期
    % 调用举例:askdigital([1 0 1 1 0], 2)
    t=0:2*pi/99:2*pi;                                     %初始化定义,1*100的矩阵
    cp=[];mod=[];bit=[];
    
    for n=1:length(s);                                   % 调制过程
        if s(n)==0; 
            bit1=zeros(1,100);   % 100是码元周期
        else  % s(n)==1; 
            bit1=ones(1,100);    
        end
        c=sin(f*t);
        mod=[mod c];    
        bit=[bit  bit1];
    end
    ask=bit.*mod;
    subplot(2,1,1);
    plot(bit,'k','LineWidth',1);grid on;        
    ylabel('Binary Signal');
    axis([0 100*length(s) -2.5 2.5]);
    subplot(2,1,2);
    plot(ask,'k','LineWidth',1);grid on;
    ylabel('ASK modulation');
    axis([0 100*length(s) -2.5 2.5]);
    

      2FSK:‘1’对应频率为$omega_1$的载波,‘0’对应频率为$omega_2$的载波。

    function fskdigital(s,f0,f1)
    % 实现 FSK 调制
    % s——输入二进制序列    f0,f1——两个不同频率的载波
    % 调用举例 (f0  f1 必须是整数) : fskdigital([1 0 1 1 0],1,2)
    t=0:2*pi/99:2*pi;                              %初始化定义
    cp=[];mod=[];bit=[];
    
    for n=1:length(s);                            % 调制过程
        if s(n)==0; 
            cp1=ones(1,100);
            c=sin(f0*t);
            bit1=zeros(1,100);
        else %s(n)==1;
            cp1=ones(1,100);
            c=sin(f1*t);
            bit1=ones(1,100);    
        end
        cp=[cp cp1];    
        mod=[mod c];    
        bit=[bit bit1];
    end
    fsk=cp.*mod;
    % fsk = mod;
    
    subplot(2,1,1);                               
    plot(bit,'k','LineWidth',1);grid on;
    ylabel('Binary Signal');
    axis([0 100*length(s) -2.5 2.5]);
    subplot(2,1,2);
    plot(fsk,'k','LineWidth',1);grid on;
    ylabel('FSK modulation');
    axis([0 100*length(s) -2.5 2.5]);
    

      或用Matlab提供的函数fskmod

    • 调用格式

      y= fskmod(x,M,freq_sep,nsamp);

      y=fskmod(x,M,freq_sep,nsamp,Fs);

    • 参数说明

      x:消息信号

      M:表示消息的符号数,必须是2的整数幂,M进制信号(0~M-1)

      freq_sep:两载波之间的频率间隔,单位Hz

      nsamp:输出信号的采样数,必须是大于1的正整数

      Fs:根据奈奎斯特采样定理,(M-1)*freq_seq <= Fs

    M=2;freqsep=8;nsamp=8;Fs=32;
    x=randi([0,M-1],1000,1);
    y=fskmod(x,M,freqsep,nsamp,Fs);
    ly = length(y);
    %画2FSK的信号频谱
    freq= -Fs/2:Fs/ly : Fs/2-Fs/ly;
    Syy = fftshift(abs(fft(y)));
    plot(freq,Syy)
    

      


    PSK

    function bpskdigital( s, f )
    %实现BPSK
    %   s:输入二进制序列,f:载波信号的频率(一个码元有几个载波周期)
    %   调用举例:bpskdigital([1 0 1 1 0], 2)
     t = 0:2*pi/99:2*pi;
     cp = [];
     mod = []; bit = [];
     for n=1:length(s)
         if s(n) == 0
             cp1 = -ones(1,100);
             bit1 = zeros(1,100);
         else %s(n)==1
             cp1 = ones(1,100);
             bit1 = ones(1,100);
         end
         c= sin(f*t);
         cp = [cp,cp1];
         mod = [mod,c];
         bit = [bit,bit1];
     end
     bpsk = cp .* mod;
     subplot(211);
     plot(bit,'LineWidth',1.5);
     grid on;
     ylabel('Binary Signal');
     axis([0 100*length(s) -2.5 2.5]);
     subplot(212);
     plot(bpsk,'LineWidth',1.5);
     grid on;
     ylabel('BPSK modulation');
     axis([0 100*length(s) -2.5 2.5]);
    
    end
    

      

    常记溪亭日暮,沉醉不知归路。兴尽晚回舟,误入藕花深处。争渡,争渡,惊起一滩鸥鹭。

    昨夜雨疏风骤,浓睡不消残酒。试问卷帘人,却道海棠依旧。知否?知否?应是绿肥红瘦。
  • 相关阅读:
    EM
    te2
    te
    XLnet
    GPT
    40.Properties
    38.特殊操作流
    37.I/O流
    35.File
    day68日考
  • 原文地址:https://www.cnblogs.com/htj10/p/9773562.html
Copyright © 2020-2023  润新知