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

📄 cck_algorithm.m

📁 补码键控调制(CCK)算法及实现
💻 M
字号:
%CCK_algorithm
clear
clc
cck_code_256 = ones(256,8); % 8-bit to 8-bit mapping
cck_code_64 = ones(64,8);  % 6-bit to 8-bit mapping

% Generate a table mapping 6-bit(b7~b2) real data to 8-bit complex data
for dec_index = 0:63, % ergod 
    bin = dec2bin(dec_index,6);
    pha1=0;
    % Calculate pha2 using b3~b2   
    switch bin(1,5:6)
        case '00'
            pha2=0;
        case '01'
            pha2=pi;
        case '10'
            pha2=pi/2;
        case '11'
            pha2=-pi/2;
    end
    % Calculate pha3 using b5~b4   
    switch bin(1,3:4)
        case '00'
            pha3=0;
        case '01'
            pha3=pi;
        case '10'
            pha3=pi/2;
        case '11'
            pha3=-pi/2;
    end
    % Calculate pha4 using b7~b6   
    switch bin(1,1:2)
        case '00'
            pha4=0;
        case '01'
            pha4=pi;
        case '10'
            pha4=pi/2;
        case '11'
            pha4=-pi/2;
    end          

    cck_code_64(dec_index+1,1:8)=[exp(i*(pha1+pha2+pha3+pha4)) ...
        exp(i*(pha1+pha3+pha4)) ...
        exp(i*(pha1+pha2+pha4)) ...
        -exp(i*(pha1+pha4)) ...
        exp(i*(pha1+pha2+pha3)) ...
        exp(i*(pha1+pha3)) ...
        -exp(i*(pha1+pha2)) ...
        exp(i*pha1)];   
end

% Generate a table mapping 8-bit(b7~b2) real data to 8-bit complex data
for dec_index = 0:255, % ergod 
    bin = dec2bin(dec_index,8);
    % Calculate pha1 using b1~b0    
    switch bin(1,7:8)
        case '00'
            pha1=0;
        case '01'
            pha1=pi;
        case '10'
            pha1=pi/2;
        case '11'
            pha1=-pi/2;
    end
    % Calculate pha2 using b3~b2   
    switch bin(1,5:6)
        case '00'
            pha2=0;
        case '01'
            pha2=pi;
        case '10'
            pha2=pi/2;
        case '11'
            pha2=-pi/2;
    end
    % Calculate pha3 using b5~b4   
    switch bin(1,3:4)
        case '00'
            pha3=0;
        case '01'
            pha3=pi;
        case '10'
            pha3=pi/2;
        case '11'
            pha3=-pi/2;
    end
    % Calculate pha4 using b7~b6   
    switch bin(1,1:2)
        case '00'
            pha4=0;
        case '01'
            pha4=pi;
        case '10'
            pha4=pi/2;
        case '11'
            pha4=-pi/2;
    end          

    cck_code_256(dec_index+1,1:8)=[exp(i*(pha1+pha2+pha3+pha4)) ...
        exp(i*(pha1+pha3+pha4)) ...
        exp(i*(pha1+pha2+pha4)) ...
        -exp(i*(pha1+pha4)) ...
        exp(i*(pha1+pha2+pha3)) ...
        exp(i*(pha1+pha3)) ...
        -exp(i*(pha1+pha2)) ...
        exp(i*pha1)];
    
end
% Pro-processing
cck_code_64=round(cck_code_64);
cck_code_256=round(cck_code_256);
save cck_code_64.mat cck_code_64 -v6
save cck_code_256.mat cck_code_256 -v6

⌨️ 快捷键说明

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