码分复用matlab仿真代码,【matlab编程代做】基于MATLAB的码分多址复用技术的仿真...

41528d3028836879cd698677c3999917.gif【matlab编程代做】基于MATLAB的码分多址复用技术的仿真

clc,clear,close all;%%%我们使用四个用户的 CDMA 系统coefficients=[1 0 1 0 0]; %5 级左移 m 序列码发生器的反馈系数mseq=mseries(coefficients); %生成 31×31 的 m 序列码矩阵walsh=[1 1 1 1;1 -1 1 -1;1 1 -1 -1;1 -1 -1 1]; %4 阶 WALSH 矩阵pn=mseq(1:31); %PN 码%四个用户发出的信号,可以随便设定user0=[ 1,-1,-1,-1,-1,-1, 1, 1, 1,-1,-1, 1, 1,-1, 1,-1, 1,-1,-1,-1,-1,-1, 1, 1, 1,-1,-1, 1, 1,-1, 1,-1];%用户 1,可以是随机信号user1=[-1,-1,-1,-1,-1, 1, 1,-1, 1,-1,-1, 1, 1, 1, 1,-1, 1,-1,-1, 1, 1,-1, 1, 1, 1,-1, 1, 1, 1,-1, 1,-1];%用户 2,可以是随机信号user2=[ 1,-1,-1,-1, 1,-1, 1, 1, 1,-1,-1, 1, 1,-1, 1, 1, 1,-1, 1,-1,-1,-1, 1, 1, 1, 1,-1, 1, 1, 1,-1,-1];%用户 3,可以是随机信号user3=[-1,-1, 1,-1,-1, 1, 1,-1, 1,-1,-1, 1, 1, 1, 1,-1, 1,-1,-1, 1,-1, 1, 1,-1, 1,-1,-1, 1, 1,-1, 1, 1];%用户 4,可以是随机信号%==========================================================================for t=1:length(user0)user=[user0(t),user1(t),user2(t),user3(t)];%四个用户分别发送 1,-1,1,1for i=1:4%四用户信号和 WALSH 矩阵相乘for j=1:4walsh_user(j,i)=user(i)*walsh(i,j);endendfor i=1:4%变成串行信号walsh_user2(4*i-3)=walsh_user(i,1);walsh_user2(4*i-2)=walsh_user(i,2);walsh_user2(4*i-1)=walsh_user(i,3);walsh_user2(4*i-0)=walsh_user(i,4);endfor i=1:31for j=1:16walsh_user3(i,j)=walsh_user2(j);endendfor i=1:31for j=1:16pn_walsh_user(i,j)=walsh_user3(i,j)*pn(i);endend%并----串for i=1:31for j=1:16pn_walsh_user_c(i*j)=pn_walsh_user(i,j);endend%以上是信号调制过程%==========================================================================%一下是信号解调过程%串----并for i=1:31for j=1:16pn_walsh_user_rec(i,j)=pn_walsh_user_c(i*j);endend%pn 解扩for i=1:31for j=1:16walsh_user_rec(i,j)=pn_walsh_user_rec(i,j)*pn(i);endendfor i=1:31for j=1:16walsh_user_rec2(j)=walsh_user_rec(i,j);endend%walsh 解扩user_rec2(1,1)=walsh_user_rec2(1);user_rec2(1,2)=walsh_user_rec2(2);user_rec2(1,3)=walsh_user_rec2(3);user_rec2(1,4)=walsh_user_rec2(4);user_rec2(2,1)=walsh_user_rec2(5);user_rec2(2,2)=walsh_user_rec2(6);user_rec2(2,3)=walsh_user_rec2(7);user_rec2(2,4)=walsh_user_rec2(8);user_rec2(3,1)=walsh_user_rec2(9);user_rec2(3,2)=walsh_user_rec2(10);user_rec2(3,3)=walsh_user_rec2(11);user_rec2(3,4)=walsh_user_rec2(12);user_rec2(4,1)=walsh_user_rec2(13);user_rec2(4,2)=walsh_user_rec2(14);user_rec2(4,3)=walsh_user_rec2(15);user_rec2(4,4)=walsh_user_rec2(16);for i=1:4for j=1:4rec(i,j)= user_rec2(i,j)*walsh(i,j);endend%===============接收信号===================================rec_signal= user_rec2(1,1:4);%========画信号==============================================================if t==1figure;subplot(511)stairs(1:4,user, r );%用户信号axis([1,4,-2,2]);title( 用户发送的信号 )subplot(512)%随机码stairs(1:31,pn);axis([1,31,-2,2]);title( 随机码 )subplot(513)%调制 WALSHstairs(1:16,walsh_user2, r );axis([1,16,-2,2]);title( 调制 WALSH )subplot(514) %发送stairs(1:496,pn_walsh_user_c);axis([1,496,-2,2]);title( 发送信号 )subplot(515) %数据接收stairs(1:4,rec_signal, r );axis([1,4,-2,2]);title( 数据接收信号 )hold on;endendfigure;subplot(411);stairs(1:32,user0);axis([1,32,-2,2]);title( user0 数据接收信号 )subplot(412);stairs(1:32,user1);axis([1,32,-2,2]);title( user1 数据接收信号 )subplot(413);stairs(1:32,us

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值