clc
close all
clear all
R = 100; % The length of the bit stream.
N = 7; % N length of Spreading Sequence
% Generation of Bit Stream
bit_stream = round(rand(1,R)); % A Randomley Generated Bit Stream.
PAM = 2*bit_stream-1; % Predefinition of the Base-band PAM signal.
subplot(1,1,1)
plot(PAM);
axis([1 R -1.2 1.2]);
title('The Original Base-Band Signal ');
% Generating the pseudo random SEQUENCE for spreading.
%pn_seq = round(rand(1,N));
pn_seq = 2*[1 1 1 0 1 0 0]-1;
subplot(1,1,2)
plot(pn_seq);
axis([1 length(pn_seq) -1.2 1.2]);
title('pseudo random SEQUENCE');
%Spread signal
spread_sig=[];
for i=1:R
spread_sig = [spread_sig PAM(i)*pn_seq];
end
subplot(1,1,3)
plot(spread_sig);
axis([1 length(spread_sig) -1.2 1.2]);
title('Spread Signal');