📄 cdma.m
字号:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Script for verifying CDMA systems for two or more users
%The file may not be re-distributed without authorization.
%check for proper operation with matlab/octave.
%Author Engr Zahoor ahmed Baloch
% Email engr_shadanzai@tahoo.com
%Date 20th may 2009
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clc
close all
N=4;
% number of bits to transmit by each user
usera=rand(1,N)>0.5;
% number of bits to transmit by user1
user1=2*usera-1;
%BPSK modulation , making 0 as -1 and 1 as 1.
userb=rand(1,N)>0.5;
% number of bits to transmit by user2
user2=2*userb-1;
user1_code=[1 -1];
%code utilized by user1
user2_code=[1 1];
%code utilized by user2
c=kron(user1,user1_code);
d=kron(user2,user2_code);
y=c+d;
%the combined information send by both users
a=ones(1,length(y)/2);
% decoding for user1
b=kron(a,user1_code);
rr=b.*y;
o=reshape(rr,2,length(rr)/2);
k=o(1,:)+o(2,:);
%decoding the message sent by user1
user1_data=k>0;
%verify for error
veryfy1=(user1_data-usera);
% decoding for user2
b=kron(a,user2_code);
ss=b.*y;
m=reshape(ss,2,length(ss)/2);
kk=m(1,:)+m(2,:);
user2_data=kk>0;
%to verify the result for error
veryfy2=(user2_data-userb);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -