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

资源简介

直接序列的matlab仿真,直接出图的,直接就可用

资源截图

代码片段和文件信息

function [Y]=DSSS(Xmode)
%完成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
            figure(1);subplot(211);plot(reshape(ascii_binary1X_length*7));title(‘A:输入数据‘);grid on;
            %扩频
            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
            figure(2);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);
            figure(3);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=

评论

共有 条评论