⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pr7_36.m

📁 Spread Spectrum and CDMA Principles and Applications 书籍和代码
💻 M
字号:
%Problem 7.36;
%multiuser reception of 21 CDMA users data; BProb 7.36; muovb;

clear all, close all;
t=cputime;
S=[1,1,1,1;-1,-1,1,1;1,-1,1,-1;1,-1,-1,1]; %Hadamard matrix of order 4;
S=kron(S,S); %Hadamard of order 16;
S1=[sum(S(1:4,:));sum(S(5:8,:));sum(S(9:12,:));sum(S(13:16,:))]/2; %supplementary signatures of the first layer;
S2=sum(S)/4; %last supplementary signature;
S=[S;S1;S2]; %complete signature matrix, signatures are rows;
B=2*unidrnd(2,1,21)-3; %data vector;
GS=B*S; %group signal;
Y=GS+normrnd(0,1,1,16); %AWGN observation;
dm=21; Bd=zeros(1,21); %initialization of distance and decision;
for k=1:2^21
    Bt=bitget(k-1,1:21); Bt=-2*Bt+1; %tentative data;
    GSt=Bt*S; %tentative group signal;
    ds=norm(GSt-Y); %distance between observation and tentative signal;
    if ds<dm dm=ds; Bd=Bt; end; %update distance and presumable data vector if current tentative vector is closest to observation;
end;
x=find(B~=Bd); %find erroneous bits;
T=cputime-t;
subplot(311); stairs([0:16],[GS,GS(16)]); ylabel('group signal'); grid; xlabel('t'); xlim([0,16]); ylim([-1.2,1.2]*max(abs(GS))); %plots group signal;
subplot(312); stairs(B); ylabel('bit'); ylim([-1.2,1.2]); xlim([1,21]); %plots true users bit pattern;
subplot(313); stairs(Bd); ylabel('bit'); ylim([-1.2,1.2]); xlim([1,21]); xlabel('user number'); %plots decisions on users bits;
fprintf('\n');
fprintf(['erroneous bits:  ',num2str(x)]); %shows where errors occure;
fprintf('\n');
fprintf('processor time= %f',T);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -