BER performance of MC-CDMA code

Status
Not open for further replies.

ukakkad

Newbie level 3
Joined
Mar 7, 2011
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Visit site
Activity points
1,317
Hi i am doing a project in MC-cdma in Matlab.I have used the following code.However i am confused as to how many cyclic prefix bits are to be used.My ber doesnot show any significant inprovement by changing the bits.Can anyone point out where i am going wrong??

clc;
clear all;
M=10^3;%no of data bits
N=128;%no of subcarriers/no of codes
cp=28;%no of cyclic prefix bits
walsh=hadamard(N);%creating the walsh hadamard code matrix
code=walsh(1,;%taking the first code for the user
user1=rand(1,M)>0.5;%generating user data
bpsk1=2*user1-1;%alloting -1 or +1
spreaded=bpsk1'*code;%spreading the signal based on the code
carr=ifft(spreaded',N);%taking the ifft of the signal
%cyclic prefix addition
carr1=carr';
carr2=[carr1,[(N-cp+1):N]) carr1];
carrier=carr2';
p0=1;% first tap
p1=0.199;%second tap
p2=0.1;% third tap
gain1=sqrt(p0/2)*(randn(1,M)+j*randn(1,M));%simulation of the appropriate gain
gain2=sqrt(p1/2)*(randn(1,M)+j*randn(1,M));
gain3=sqrt(p2/2)*(randn(1,M)+j*randn(1,M));
delay1=1;%assuming sample delay of one and two for the paths
delay2=2;
carrier1=carrier);
x=reshape(carrier1,1,length(carrier1));%conversion into a row matrix
for i=delay1+1:length(x)
x1(i)=x(i-delay1);%producing the delay
end
for i=delay2+1:length(x)
x2(i)=x(i-delay2);
end
x11=reshape(x1,(N+cp),length(x1)/(N+cp));%reshaping in the form of the original matrix
x22=reshape(x2,(N+cp),length(x2)/(N+cp));
ch1=repmat(gain1,(N+cp),1);%representing the row matrix in the N X M matrix
ch2=repmat(gain2,(N+cp),1);
ch3=repmat(gain3,(N+cp),1);
xchan=carrier.*ch1+x11.*ch2+x22.*ch3;%multiplication with the channel
xch1=xchan);
xch2=reshape(xch1,1,length(xch1));%coversion into row matrix for adding noise
noise=sqrt(0.5)*(randn(1,length(xch2))+j*randn(1,length(xch2)));%generation of the noise vector
snr=[0:15];%Eb/N0 values in db
for i=1:length(snr)
datarxd=xch2+10^(-snr(i)/20)*noise;%adding the noise to the signal
datatrx=reshape(datarxd,(N+cp),length(datarxd)/(N+cp));%conversion into the N X M data matrix
datatr=datatrx';
datatr1=datatr,[cp+1:N+cp]);
datatrans=datatr1';
yrxd=fft(datatrans,N);%reverse receiver process taking FFT
channel=fft([gain1;gain2;gain3],(N));%the channel frequency response
y=yrxd.*conj(channel);%signal recovery
despread=y'*code';%despreading
recover=real(despread)>0;%decision making
rec1=recover';
error(i)=size(find([rec1- user1]),2);%finding the no of bit errors
Ber=error/N;%Bit Error rate
end
semilogy(snr,Ber);
axis([0 15 10^-3 1]);
legend('Simulated BER for User');
xlabel('Eb/No, dB');
ylabel('Bit Error Rate');
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…