DS-CDMA数字基带传输系统+MATLAB仿真图+程序代码(2)

2019-01-10 12:50

IPOINT = 4; % 码片速率过采样倍数(4倍

alfs = 0.22; % 滚降因子

[xh] = hrollfcoef(irfn,IPOINT,sr,alfs,1); %发送端根升余弦滤波器系数 %%hrollfcoef指

[xh2] = hrollfcoef(irfn,IPOINT,sr,alfs,0); %接收端根升余弦滤波器系数

%++++++++++++++++++++++++扩频码初值设定+++++++++++++++++++ user = 4; % 用户数

%seq = 2; % 1:m序列 2:Gold序列 3:正交Gold序列 stage = 5; % 序列阶数

ptap1 = [2 5]; % 第一个线性移位寄存器的系数 ptap2 = [1 2 3 5]; % 第二个线性移位寄存器的系数 regi1 = [1 1 1 1 1]; % 第一个线性移位寄存器的初始化 regi2 = [1 1 1 1 1]; % 第二个线性移位寄存器的初始化 %移位寄存器级数 3,码长 7.

% 5 31

%+++++++++++++++++扩频码的产生+++++++++++++++++ m1 = mseq(stage,ptap1,regi1); m2 = mseq(stage,ptap2,regi2);

code = [goldseq(m1,m2,user),zeros(user,1)]; %正交 Gold序列 code = code * 2 - 1; %双极性 clen = length(code);

data = rand(user,nd) > 0.5; dlen = length(data);

data_m = data.*2 -1; %QPSK; data_s=zeros(user,dlen*(2^stage));

for i1=1:1:user %扩频 data_s(i1,:)=kron(data_m(i1,:),code(i1,:));

end

data_os = compoversamp2(data_s,IPOINT); % 过采样 data_f1 = compconv2(data_os,xh); % 滤波

if user == 1

data_f = data_f1; else

data_f = sum(data_f1); end

disp('--------------Send Data ...-------------------'); loo=0;

for kk=1:1:length(SNR)

data_n=awgn(data_f,SNR(kk),'measured');%在信号data_f中加入高斯白噪声

data_rf = compconv2(data_n,xh2); % 滤波

sampl = irfn * IPOINT + 1;

data_ros = data_rf(:,sampl:IPOINT:IPOINT*nd*clen+sampl-1); %减采样

%++++++++++解扩++++++++ data_rs=zeros(user,dlen); scused=ones(1,dlen);

for i2=1:1:user

bds=kron(scused,code(i2,:)); %将Gold码矩阵的i2行,复制scused次 ds=bds.*data_ros(1,:); %反哈达玛变换(解扩)

rds=reshape(ds,clen,length(data_ros(1,:))/clen);%对ds重新排列成 hl行,length(s)/hl。

%注:(reshape数据排列顺序:从上往下,从左往右)

ou=sum(rds); %对每列求和 t=length(ou);

en=zeros(1,t); for a=1:t

if ou(a)>1 %抽样判决 en(a)=1; else

en(a)=-1; end end

data_rs(i2,:)=en; end

%++++++++++++++++++

data_rm=(data_rs+1)./2;%BPSK解调 loo=loo+1;

[n(loo),r(loo)]=symerr(data_m,data_rs); %[number,ratio] = symerr(x,y) end

disp('----------------Calculate Finished-------------------'); disp('----------------Start Plot-------------------'); %根升余弦滤波器

figure('Name','根升余弦滤波器','NumberTitle','on'); % Tx

subplot(211);stem(xh);grid; xlabel('Bits index');

title('发送端根升余弦滤波器'); % Rx

subplot(212);stem(xh2);grid; xlabel('Bits index');

title('接收端根升余弦滤波器'); %误码率-信噪比关系图

figure; % plot the BER vs. SNR semilogy(SNR,r,'r-x'),grid; xlabel('SNR');ylabel('BER'); title('BER vs. SNR');

%原始数据,发送和接收的比较

figure('Name','Original Data','NumberTitle','on');

% plot data for a randomly selected user such as user no. 1 before the BPSK mapping Tx and Rx

% Tx

subplot(211);stem(data(cuser,1:20),'filled');grid; xlabel('Bits index');

title('Transmitted Bits (showing only 20 bits)'); % Rx

subplot(212);stem(data_rm(cuser,1:20),'filled');grid; xlabel('Bits index');

title('Received Bits (showing only 20 bits)');

%BPSK编码后,发送和接收的比较

figure('Name','BPSK Symbols','NumberTitle','on');

% plot data for a randomly selected user such as user no. 1 after the BPSK mapping Tx and Rx

% Tx

subplot(211);stem(data_m(cuser,1:20),'filled');grid; xlabel('Symbol index');

title('Transmitted BPSK Symbols (showing only 20 Symbol)'); % Rx

subplot(212);stem(data_rs(cuser,1:20),'filled');grid;

xlabel('Symbol index');

title('Received BPSK Symbols (showing only 20 Symbol)');

%要发送的数据,各个用户对应位求和的结果

figure('Name','Combined signals','NumberTitle','on');%plot combined signals %Tx

subplot(211);stem(data_f(1:50),'filled'); title('Combined signals (only 20 symbols)'); xlabel('Index of Combined symbols'); ylabel('Magnitude'); grid;

%Rx

subplot(212);stem(data_ros(1:50),'filled'); title('Combined noisy signals (only 20 symbols)'); xlabel('Index of Combined symbols');

ylabel('Magnitude'); grid;

disp('----------------Plot Finished-------------------');


DS-CDMA数字基带传输系统+MATLAB仿真图+程序代码(2).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:U-BOOT中文文档 概述与配置选项

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: