📄 pr4_13.m
字号:
%Problem 4.13;
%simulates K users FDMA;
clear all, close all;
K=5; %number of users, take it within 3...8;
t=[0:0.01:0.99]; %time scale;
f=[5:5+K-1]; %vector of subcarrier frequencies;
S=cos(2*pi*(f'*t)); %K subcarriers;
A0=2*unidrnd(2,K,2)-3; A=kron(A0,ones(1,100)); %bitstream matrix;
Sa=A.*[S,S]; %K subcarriers modulated by users bitstreams;
Y=sum(Sa); %group signal (noiseless observation);
subplot(321); plot([t,t+1],Sa(1,:)); ylim([-1.2 1.2]); grid; xlim([0,1.99]); ylabel('1st user signal'); %plotting signal of 1st user;
subplot(323); plot([t,t+1],Sa(K,:)); ylim([-1.2 1.2]); grid; xlim([0,1.99]); ylabel('Kth user signal'); %plotting signal of K-th user;
subplot(325); plot([t,t+1],Y); ylim([-K K]); grid; xlim([0,1.99]); xlabel ('t/T'); ylabel('group signal'); %plotting a group sgnal;
subplot(322); plot([t,t+1],Y); ylim([-K K]); grid; xlim([0,1.99]); xlabel ('t/T'); ylabel('group signal'); %plotting a group sgnal again;
Mul=(ones(K,1)*Y).*[S,S]; %multiplication of group signal by all K references, i.e.carriers;
Rec=cumtrapz(Mul')/(norm(S(1,:))^2); Rec=Rec'; Rec(:,101:200)=Rec(:,101:200)-kron(ones(1,100),Rec(:,100)); %integration-and-dump for all K user's receivers;
subplot(324); plot([t,t+1],Rec(1,:)); ylim([-1.2,1.2]); xlim([0,1.99]); ylabel('1st user demod'); grid; %plotting 1st user integrator output;
subplot(326); plot([t,t+1],Rec(K,:)); ylim([-1.2,1.2]); xlim([0,1.99]); ylabel('K th user demod'); grid; %plotting K-th user integrator output;
Dc=sign([Rec(:,100),Rec(:,200)]); %demodulation;
disp(' sent bits demod bits');
disp([A0,Dc]);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -