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

📄 lab1.asv

📁 Matlab 模拟 CDMA 直接扩频。m序列生成矩阵为p(x) = 1 + x^5 + x^7 + x^8 + x^9 + x^13 + x^15。能画出每阶段的时域、频域图。
💻 ASV
字号:
%% Created By ZHENG XIAO (052815 05b04)

%==== ENCODER ==>==%
%%tk=0:1/16:1024;
tk=0:1/16:1;
%s=sin(2*pi*tk)+cos(pi*tk);
%s=2*sin(2*pi*tk);
s=0:0.005:2;
%%plot(s)
%APMout= compand(s,87.6,2,'A/compressor');
SLENGTH = length(s); % Length of the sampled signal

UniS=s/2; %Unified Input signal (max value = 1)
PCMout=zeros(1,SLENGTH);

ABYTE=zeros(3,SLENGTH);
for i = 1:SLENGTH,
    Byte=zeros(1,3);

    % Determine the Sign ('+' => 0; '-' => 1)!
    if UniS(i) >= 0,
        Byte(1) = 0;
    else
        Byte(1) = 1;
    end
    
    % Determine the Segment Code
    for j = 1:8,
        if abs(UniS(i)) >= (1/2)^j,
            Byte(2) = 8-j;
            break;
        end
    end
    
    % Determine the Inner Segment Code
    if Byte(2) == 0, % This is for the points in segment 0 % in case!
        preByte = (1/2)^7;
        preByte1 = 0;
    else
        preByte = (1/2)^(8-Byte(2));
        preByte1 = preByte;
    end
    for j = 1:16,
        if (abs(UniS(i))-preByte1) >= preByte*(16-j)/16
            Byte(3) = 16-j;
            break;
        end
    end
    clear preByte;
    
    % Convert Byte's value to bit and 
    % put Byte's value into PCMout array
    PCMout(i) = Byte(1)*2^7 + Byte(2)*2^4 + Byte(3);
    % debug
    ABYTE(1,i)=Byte(1);
    ABYTE(2,i)=Byte(2);
    ABYTE(3,i)=Byte(3);
end

PCMout;
DEC2BIN(PCMout);
ABYTE; % <== This is the Decoder's required input

% Generate the Digintal Signal
bits = [];
for i=1:SLENGTH,
    aBit = bitget(PCMout(i),8:-1:1)
    bits = [bits aBit];
end
clear aBit;

%%---------------------------------
bitsIn = bits; %% Transmitting!!!!

%ABYTE = ABYTEIn;

⌨️ 快捷键说明

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