444
444
end
code1=t1;
code3=t3;
%------------------Generation of chaotic sequence with Logistic Map2--------
t4(1)=0.2303;
for i=1:SF-1
%t3(i+1)= (4*t3(i).*(1-t3(i)));
%t3(i+1)=3*t3(i)-4*t3(i).^3;
t4(i+1)=4*t4(i).^3-3*t4(i);
%t3(i+1)=1-2*t3(i).*t3(i);
end
code4=t4;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
x=zeros(1,M*N);
y=zeros(1,M*N);
x5=zeros(1,M*N);
y5=zeros(1,M*N);
x7=zeros(1,M*N);
y7=zeros(1,M*N);
x9=zeros(1,M*N);
y9=zeros(1,M*N);
%%%%%%%%%%%%%%%%%%%%%%%%%%%Cubic_Functions%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
x(1)=0.12;
for i=1:M*N-1
x(i+1)=4*x(i).^3-3*x(i);
%x(i+1)= (4*x(i).*(1-x(i)));
end
y(1)=0.112;
for i=1:M*N-1
y(i+1)=4*y(i).^3-3*y(i);
%y(i+1)= (4*y(i).*(1-y(i)));
end
x5(1)=0.22;
for i=1:M*N-1
x5(i+1)=4*x5(i).^3-3*x5(i);
%x5(i+1)= (4*x5(i).*(1-x5(i)));
end
y5(1)=0.212;
for i=1:M*N-1
y5(i+1)=4*y5(i).^3-3*y5(i);
%y5(i+1)= (4*y5(i).*(1-y5(i)));
end
x7(1)=0.32;
for i=1:M*N-1
x7(i+1)=4*x7(i).^3-3*x7(i);
%x7(i+1)= (4*x7(i).*(1-x7(i)));
end
y7(1)=0.312;
for i=1:M*N-1
y7(i+1)=4*y7(i).^3-3*y7(i);
%y7(i+1)= (4*y7(i).*(1-y7(i)));
end
x9(1)=0.42;
for i=1:M*N-1
x9(i+1)=4*x9(i).^3-3*x9(i);
%x(i+1)= (4*x(i).*(1-x(i)));
end
y9(1)=0.412;
for i=1:M*N-1
y9(i+1)=4*y9(i).^3-3*y9(i);
%y(i+1)= (4*y(i).*(1-y(i)));
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
data=sign(randn(1,N));
data5=sign(randn(1,N));
data7=sign(randn(1,N));
data9=sign(randn(1,N));
for j1=1:N
if data(j1)>0
d(j1)=1;
else % CSK modulation 0 -> -1; 1 -> 0
d(j1)=0;
end
end
for j1=1:N
if data5(j1)>0
d5(j1)=1;
else % CSK modulation 0 -> -1; 1 -> 0
d5(j1)=0;
end
end
for j1=1:N
if data7(j1)>0
d7(j1)=1;
else % CSK modulation 0 -> -1; 1 -> 0
d7(j1)=0;
end
end
for j1=1:N
if data9(j1)>0
d9(j1)=1;
else % CSK modulation 0 -> -1; 1 -> 0
d9(j1)=0;
end
end
for i=1:N
if d(i)==1
x1(i,:)=x(((i-1)*M+1):i*M);
else %% Making Both row vector to a matrix
x1(i,:)=y(((i-1)*M+1):i*M) ;
end
end
for i=1:N
if d5(i)==1
x15(i,:)=x5(((i-1)*M+1):i*M);
else %% Making Both row vector to a matrix
x15(i,:)=y5(((i-1)*M+1):i*M) ;
end
end
for i=1:N
if d7(i)==1
x17(i,:)=x7(((i-1)*M+1):i*M);
else %% Making Both row vector to a matrix
x17(i,:)=y7(((i-1)*M+1):i*M) ;
end
end
for i=1:N
if d9(i)==1
x19(i,:)=x9(((i-1)*M+1):i*M);
else %% Making Both row vector to a matrix
x19(i,:)=y9(((i-1)*M+1):i*M) ;
end
end
noises = (1/sqrt(2))*[randn(1,length(data_noise2s)) +
j*randn(1,length(data_noise2s))];
eb1=(sum(d.^2)/length(d))*Tb1;
eb2=(sum(d5.^2)/length(d5))*Tb1;
eb3=(sum(d7.^2)/length(d7))*Tb1;
eb4=(sum(d9.^2)/length(d9))*Tb1;
ebn0=10.^(EbN0dB/10);
n01=eb1./ebn0;
pn1=n01*fs2/2; %Variance
sigma1=sqrt(pn1);
n02=eb2./ebn0;
pn2=n02*fs2/2; %Variance
sigma2=sqrt(pn2);
n03=eb3./ebn0;
pn3=n03*fs2/2; %Variance
sigma3=sqrt(pn3);
n04=eb4./ebn0;
pn4=n04*fs2/2; %Variance
sigma4=sqrt(pn4);
sigma=sigma1.*sigma2.*sigma3.*sigma4;
for i1=1:length(EbN0dB)
%--------------------------Receiver-------------------------------------
data_received =yc; %fadded data received with awgn noise
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
for j1=1:length(EbN0dB)
rk1=recdata11.*x;
rk2=recdata11.*y;
%????
for n=1:(length(rk1)/M)
zl1(n)=sum(rk1(((n-1)*M+1):n*M));
zl2(n)=sum(rk2(((n-1)*M+1):n*M));
end
zz=zl1-zl2;
for m=1:N
if zz(m)>=0
zz1(m)=1;
else
zz1(m)=0;
end
end
%ber(j)=sum((abs(d-zz1))/length(d));
end
recdata12s=sign((zz));
errors_user1s(i1) = size(find([data - recdata12s]),2); %Errors for User1
SBer1 = errors_user1s/N; % simulated ber user1
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
for j1=1:length(EbN0dB)
rk15=recdata115.*x5;
rk25=recdata115.*y5;
%????
for n=1:(length(rk15)/M)
zl15(n)=sum(rk15(((n-1)*M+1):n*M));
zl25(n)=sum(rk25(((n-1)*M+1):n*M));
end
zz5=zl15-zl25;
for m=1:N
if zz5(m)>=0
zz15(m)=1;
else
zz15(m)=0;
end
end
%ber(j1)=sum((abs(d-zz1))/length(d));
end
recdata12s5=sign((zz5));
errors_user1s5(i1) = size(find([data5 - recdata12s5]),2); %Errors for User1
SBer15 = errors_user1s5/N; % simulated ber user1
% simulated ber user1
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
for j1=1:length(EbN0dB)
rk17=recdata117.*x7;
rk27=recdata117.*y7;
%????
for n=1:(length(rk17)/M)
zl17(n)=sum(rk17(((n-1)*M+1):n*M));
zl27(n)=sum(rk27(((n-1)*M+1):n*M));
end
zz7=zl17-zl27;
for m=1:N
if zz7(m)>=0
zz17(m)=1;
else
zz17(m)=0;
end
end
%ber(j1)=sum((abs(d-zz1))/length(d));
end
recdata12s7=sign((zz7));
errors_user1s7(i1) = size(find([data7 - recdata12s7]),2); %Errors for User1
SBer17 = errors_user1s7/N; % simulated ber user1
%----------------BER of Data User4-----------------------------------------
recdata119=real(fft_data_received'*code4')';
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
for j1=1:length(EbN0dB)
rk19=recdata119.*x9;
rk29=recdata119.*y9;
%????
for n=1:(length(rk19)/M)
zl19(n)=sum(rk19(((n-1)*M+1):n*M));
zl29(n)=sum(rk29(((n-1)*M+1):n*M));
end
zz9=zl19-zl29;
for m=1:N
if zz9(m)>=0
zz19(m)=1;
else
zz19(m)=0;
end
end
%ber(j)=sum((abs(d-zz1))/length(d));
end
recdata12s9=sign((zz9));
errors_user1s9(i1) = size(find([data9 - recdata12s9]),2); %Errors for User1
SBer19 = errors_user1s9/N; % simulated ber user1
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
xh=zeros(1,M*N);
yh=zeros(1,M*N);
xh5=zeros(1,M*N);
yh5=zeros(1,M*N);
xh7=zeros(1,M*N);
yh7=zeros(1,M*N);
xh9=zeros(1,M*N);
yh9=zeros(1,M*N);
%%%%%%%%%%%%%%%%%%%%%%%%%%%Cubic_Functions%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
xh(1)=0.1;
for i=1:M*N-1
xh(i+1)=4*xh(i).^3-3*xh(i);
end
yh(1)=0.11;
for i=1:M*N-1
yh(i+1)=4*yh(i).^3-3*yh(i);
end
xh5(1)=0.2;
for i=1:M*N-1
xh5(i+1)=4*xh5(i).^3-3*xh5(i);
end
yh5(1)=0.21;
for i=1:M*N-1
yh5(i+1)=4*yh5(i).^3-3*yh5(i);
end
xh7(1)=0.3;
for i=1:M*N-1
xh7(i+1)=4*xh7(i).^3-3*xh7(i);
end
yh7(1)=0.31;
for i=1:M*N-1
yh7(i+1)=4*yh7(i).^3-3*yh7(i);
end
xh9(1)=0.4;
for i=1:M*N-1
xh9(i+1)=4*xh9(i).^3-3*xh9(i);
end
yh9(1)=0.41;
for i=1:M*N-1
yh9(i+1)=4*yh9(i).^3-3*yh9(i);
end
datah=sign(randn(1,N));
datah5=sign(randn(1,N));
datah7=sign(randn(1,N));
datah9=sign(randn(1,N));
for j1=1:N
if datah(j1)>0
dh(j1)=1;
else % CSK modulation 0 -> -1; 1 -> 0
dh(j1)=0;
end
end
for j1=1:N
if datah5(j1)>0
dh5(j1)=1;
else % CSK modulation 0 -> -1; 1 -> 0
dh5(j1)=0;
end
end
for j1=1:N
if datah7(j1)>0
dh7(j1)=1;
else % CSK modulation 0 -> -1; 1 -> 0
dh7(j1)=0;
end
end
for j1=1:N
if datah9(j1)>0
dh9(j1)=1;
else % CSK modulation 0 -> -1; 1 -> 0
dh9(j1)=0;
end
end
for i=1:N
if dh(i)==1
x1h(i,:)=xh(((i-1)*M+1):i*M);
else %% Making Both row vector to a matrix
x1h(i,:)=yh(((i-1)*M+1):i*M) ;
end
end
for i=1:N
if dh5(i)==1
x1h5(i,:)=xh5(((i-1)*M+1):i*M);
else %% Making Both row vector to a matrix
x1h5(i,:)=yh5(((i-1)*M+1):i*M) ;
end
end
for i=1:N
if dh7(i)==1
x1h7(i,:)=xh7(((i-1)*M+1):i*M);
else %% Making Both row vector to a matrix
x1h7(i,:)=yh7(((i-1)*M+1):i*M) ;
end
end
for i=1:N
if dh9(i)==1
x1h9(i,:)=xh9(((i-1)*M+1):i*M);
else %% Making Both row vector to a matrix
x1h9(i,:)=yh9(((i-1)*M+1):i*M) ;
end
end
noisesh = (1/sqrt(2))*[randn(1,length(data_noise2sh)) +
j*randn(1,length(data_noise2sh))];
ebh1=(sum(dh.^2)/length(dh))*Tb1;
ebh2=(sum(dh5.^2)/length(dh5))*Tb1;
ebh3=(sum(dh7.^2)/length(dh7))*Tb1;
ebh4=(sum(dh9.^2)/length(dh9))*Tb1;
ebn0h=10.^(EbN0dB/10);
n0h1=ebh1./ebn0h;
pnh1=n0h1*fs2/2; %Variance
sigmah1=sqrt(pnh1);
n0h2=ebh2./ebn0h;
pnh2=n0h2*fs2/2; %Variance
sigmah2=sqrt(pnh2);
n0h3=ebh3./ebn0h;
pnh3=n0h3*fs2/2; %Variance
sigmah3=sqrt(pnh3);
n0h4=ebh4./ebn0h;
pnh4=n0h4*fs2/2; %Variance
sigmah4=sqrt(pnh4);
sigmah=sigmah1.*sigmah2.*sigmah3.*sigmah4;
for i1=1:length(EbN0dB)
%--------------------------Receiver ---------------------------------------
data_receivedh =ych; %fadded data received with awgn noise
%---------------------Removing Cyclic Prefix-------------------------------
rx1h=reshape(data_receivedh,(n1+cp),length(data_receivedh)/(n1+cp));
rx12h=rx1h';
rx13h = rx12h(:,(cp+1 :n1+cp));
rx14h=rx13h';
%-----------------Taking FFT ----------------------------------------------
fft_data_receivedh =fft(rx14h);
%----------------BER of Data User1-----------------------------------------
recdata11h=real(fft_data_receivedh'*code11')';
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
for j1=1:length(EbN0dB)
rk1h=recdata11h.*xh;
rk2h=recdata11h.*yh;
%????
for n=1:(length(rk1h)/M)
zl1h(n)=sum(rk1h(((n-1)*M+1):n*M));
zl2h(n)=sum(rk2h(((n-1)*M+1):n*M));
end
zzh=zl1h-zl2h;
for m=1:N
if zzh(m)>=0
zz1h(m)=1;
else
zz1h(m)=0;
end
end
%ber(j1)=sum((abs(d-zz1))/length(d));
end
recdata12sh=sign((zzh));
errors_user1sh(i1) = size(find([datah - recdata12sh]),2); %Errors for User1
SBer1h = errors_user1sh/N; % simulated ber user1
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
for j1=1:length(EbN0dB)
rk1h5=recdata11h5.*xh5;
rk2h5=recdata11h5.*yh5;
%????
for n=1:(length(rk1h5)/M)
zl1h5(n)=sum(rk1h5(((n-1)*M+1):n*M));
zl2h5(n)=sum(rk2h5(((n-1)*M+1):n*M));
end
zzh5=zl1h5-zl2h5;
for m=1:N
if zzh5(m)>=0
zz1h5(m)=1;
else
zz1h5(m)=0;
end
end
%ber(j1)=sum((abs(d-zz1))/length(d));
end
recdata12sh5=sign((zzh5));
errors_user1sh5(i1) = size(find([datah5 - recdata12sh5]),2); %Errors for User1
SBer1h5 = errors_user1sh5/N; % simulated ber
user1
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
for j1=1:length(EbN0dB)
rk1h7=recdata11h7.*xh7;
rk2h7=recdata11h7.*yh7;
%????
for n=1:(length(rk1h7)/M)
zl1h7(n)=sum(rk1h7(((n-1)*M+1):n*M));
zl2h7(n)=sum(rk2h7(((n-1)*M+1):n*M));
end
zzh7=zl1h7-zl2h7;
for m=1:N
if zzh7(m)>=0
zz1h7(m)=1;
else
zz1h7(m)=0;
end
end
%ber(j1)=sum((abs(d-zz1))/length(d));
end
recdata12sh7=sign((zzh7));
errors_user1sh7(i1) = size(find([datah7 - recdata12sh7]),2); %Errors for User1
SBer1h7 = errors_user1sh7/N; % simulated ber
user1
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
for j1=1:length(EbN0dB)
rk1h9=recdata11h9.*xh9;
rk2h9=recdata11h9.*yh9;
%????
for n=1:(length(rk1h9)/M)
zl1h9(n)=sum(rk1h9(((n-1)*M+1):n*M));
zl2h9(n)=sum(rk2h9(((n-1)*M+1):n*M));
end
zzh9=zl1h9-zl2h9;
for m=1:N
if zzh9(m)>=0
zz1h9(m)=1;
else
zz1h9(m)=0;
end
end
%ber(j1)=sum((abs(d-zz1))/length(d));
end
recdata12sh9=sign((zzh9));
errors_user1sh9(i1) = size(find([datah9 - recdata12sh9]),2); %Errors for User1
SBer1h9 = errors_user1sh9/N; % simulated ber
user1
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
noisesp = (1/sqrt(2))*[randn(1,length(data_noise2sp)) +
j*randn(1,length(data_noise2sp))];
for i1=1:length(EbN0dB)
ycp = data_noise2sp + (sqrt(1)*10^(-EbN0dB(i1)/20))*noisesp; %Addition of
Noise %3 TOP
% ycp = data_noise2sp +
(sqrt(1)*10^(-EbN0dB(i)/20))*randn(1,length(data_noise2sp)); %Addition of
Noise %3 TOP
%--------------------------Receiver ---------------------------------------
data_receivedp =ycp; %fadded data received with awgn noise
%---------------------Removing Cyclic Prefix-------------------------------
rx1p=reshape(data_receivedp,(n1+cp),length(data_receivedp)/(n1+cp));
rx12p=rx1p';
rx13p = rx12p(:,(cp+1 :n1+cp));
rx14p=rx13p';
%-----------------Taking FFT ----------------------------------------------
fft_data_receivedp =fft(rx14p);
%----------------BER of Data User1-----------------------------------------
recdata11p=(fft_data_receivedp'*code1')';
recdata12p=real(recdata11p)>0;
errors_user1p(i1) = size(find([data_user1- recdata12p]),2); %Errors for User1
SBer1p = errors_user1p/N; % simulated ber user1
noisesc = (1/sqrt(2))*[randn(1,length(data_noise2sc)) +
j*randn(1,length(data_noise2sc))];
% for i = 1:length(snr)
for i1=1:length(EbN0dB)
ycc = data_noise2sc + (sqrt(1)*10^(-EbN0dB(i1)/20))*noisesc ; %Addition of
Noise %3 TOP noisesp
% ycc = data_noise2sc +
(sqrt(1)*10^(-EbN0dB(i)/20))*randn(1,length(data_noise2sc)); %Addition of
Noise %3 TOP
%--------------------------Receiver ---------------------------------------
data_receivedc =ycc; %fadded data received with awgn noise
%---------------------Removing Cyclic Prefix-------------------------------
rx1c=reshape(data_receivedc,(n1+cp),length(data_receivedc)/(n1+cp));
rx12c=rx1c';
rx13c = rx12c(:,(cp+1 :n1+cp));
rx14c=rx13c';
%-----------------Taking FFT ----------------------------------------------
fft_data_receivedc =fft(rx14c);
%----------------BER of Data User1-----------------------------------------
recdata11c=(fft_data_receivedc'*code11')';
recdata12c=real(recdata11c)>0;
errors_user1c(i1) = size(find([data_user1c- recdata12c]),2); %Errors for User1
SBer1c = errors_user1c/N; % simulated ber user1
%----------------BER of Data User2-----------------------------------------
recdata11c5=(fft_data_receivedc'*code22')';
recdata12c5=real(recdata11c5)>0;
errors_user1c5(i1) = size(find([data_user1c5- recdata12c5]),2); %Errors for
User1
SBer1c5 = errors_user1c5/N; % simulated ber user1
semilogy(EbN0dB,SBer1h,'gp-','LineWidth',2);
hold on;
semilogy(EbN0dB,SBer1h5,'g*-','LineWidth',2);
hold on;
semilogy(EbN0dB,SBer1h7,'gs-','LineWidth',2);
hold on;
semilogy(EbN0dB,SBer1h9,'g>-','LineWidth',2);
hold on;
grid on;
xlabel('Eb/No, dB');
ylabel('BER');
semilogy(EbN0dB,SBer1p,'bp-','LineWidth',2);
hold on;
semilogy(EbN0dB,SBer1p5,'b*-','LineWidth',2);
hold on;
semilogy(EbN0dB,SBer1p7,'bs-','LineWidth',2);
hold on;
semilogy(EbN0dB,SBer1p9,'b>-','LineWidth',2);
hold on;
grid on;
xlabel('Eb/No, dB');
ylabel('BER');
semilogy(EbN0dB,SBer1c,'rp-','LineWidth',2);
hold on;
semilogy(EbN0dB,SBer1c5,'r*-','LineWidth',2);
hold on;
semilogy(EbN0dB,SBer1c7,'rs-','LineWidth',2);
hold on;
semilogy(EbN0dB,SBer1c9,'r>-','LineWidth',2);
hold on;
grid on;
xlabel('Eb/No, dB');
ylabel('BER');