• 大小: 1KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-06-04
  • 语言: Matlab
  • 标签: DSSS  MATLAb  

资源简介

关于直扩序列DSSS的MATLAb仿真 希望对大家有用 ~~~~~~~~~~~~~

资源截图

代码片段和文件信息

function [Y]=DSSS(X mode)
% 完成DSSS调制解调功能
% mode=[12].  1进行调制,2进行解调,未指定时自动完成调制和解调两个功能。
switch nargin
    case 0
        X=‘This is a test.‘;
        Y=DSSS(X);
        return
    case 1
        Y1=DSSS(X 1); 
        Y2=DSSS(Y1 2);
        Y=Y2;
        return;
    case 2
        if mode==1%调制
            D=ones(17);
            m_sequence=Msequence(D);
            X_length=length(X);
            ascii_value=abs(X);
            ascii_binary=zeros(X_length7);
            %将数据转换为ASCII二进制码
            for ii=1:X_length
                ascii_binary(ii:)=Binary(ascii_value(ii));
            end
            subplot(231);plot(reshape(ascii_binary1X_length*7));title(‘A:输入数据‘);
            %扩频
            Sp_expand=zeros(X_length127*7);
            for ii=1:X_length
                for jj=1:7
                    Sp_expand(ii127*jj-126:127*jj)=xor(m_sequenceascii_binary(iijj));
                end
            end
            subplot(232);plot(reshape(Sp_expand1X_length*127*7));title(‘B:数据扩展‘);
            %将扩频码转换为BPSK(1-1)序列
            for ii=1:X_length
                for jj=1:127*7
                    if~(Sp_expand(iijj))
                        Sp_expand(iijj)=-1;
                    end
                end
            end
            Sp_expand_bpsk=reshape(Sp_expand1X_length*127*7);
            subplot(233);plot(Sp_expand_bpsk);title(‘C:BPSK调制‘)
            Y=Sp_expand_bpsk;
        elseif mode==2%解调
            D=ones(17);
            m_sequence=Msequence(D);
            %将BPSK双极性转换为单极性
            l=length(X)/(127*7);
            X_length=length(X);
            for ii=1:X_length
                if X(ii)==-1
                    X(ii)=0;
                end
            end
            Sp_expand=reshape(Xl127*7);
            subplot(234);plot(X);title(‘D:数据传输‘);
            ascii_binary=zeros(l7);
            Demodulate_binary=zeros(l127*7);
            %接收处解调
            for ii=1:l
                for jj=1:7
                    Demodulate(ii127*jj-126:127*jj)=xor(m_sequence Sp_expand(ii127*jj-126:127*jj));
                end
            end
            for ii=1:l
                for jj=1:7
                    ascii_binary(iijj)=Demodulate(ii127*jj-126);
                end
            end
            subplot(236);plot(reshape(ascii_binary1l*7));title(‘E:数据输出‘);
            %将ASCII二进制转换为输出数据
            A=zeros(1l);
            for ii=1:l
                A(ii)=Ascii(ascii_binary(ii:));
            end
            Y=char(A);
        else
            mode=1;
        end
        return
end
%代码主体,执行中画出各点波形。
%ASCII数值二进制比特转换
function [YY]=Binary(Z1)
z=zeros(17);
z(1)=mod(Z12);
a=floor(Z1/2);
for ll=1:6
    z(ll+1)=mod(a2);
    a=floor(a/2);
    if a==0
        break;
    end
end
YY=z;
%二进制比特转换为ASCII数值
function [ZZ]=Ascii(Z2)
l=length(Z2);
A=0;
for ii=1:l
    A=Z2(ii)*2^(ii-1)+A;
end
ZZ=A;
%生成m序列
function [Y]=

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       3743  2010-04-13 16:35  DSSS.m

----------- ---------  ---------- -----  ----

                 3743                    1


评论

共有 条评论