channel - aalto · rake receiver to use rake receiver, we must have a good channel estimation. in...

14
Channel %set multipath delay1=2; delay2=5; channel=zeros(1,delay2+1); channel(1)=randn; channel(1+delay1)=randn; channel(1+delay2)=randn; channel=channel/norm(channel); Here, we have a 3-tap multipath channel, the “channel” in the code denotes the Channel Impulse Response (CIR).

Upload: ngonguyet

Post on 27-Sep-2018

223 views

Category:

Documents


0 download

TRANSCRIPT

Channel

%set multipathdelay1=2;delay2=5;channel=zeros(1,delay2+1);channel(1)=randn;channel(1+delay1)=randn;channel(1+delay2)=randn;

channel=channel/norm(channel);

Here, we have a 3-tap multipath channel, the “channel” in the code denotes the Channel Impulse Response (CIR).

%source generationsource=sign(randn(1,Nd));source_in_dB=10*log10(std(source)^2);%Code Generationcode=CodeGenerate(1,Lc);%Spreadingtemp1=code'*source;transmission=reshape(temp1,1,Lc*Nd);%Passing the channelreceive=conv(channel,transmission);%added noisenoise_in_dB=source_in_dB-SNR(dB);noise=wgn(size(receive,1), size(receive,2),noise_in_dB);receive_n=receive+noise;

As we know that the Rake receiver is used in CDMA system, so we have this code generation function here, then spread the source with the code before transmission.

Convolute the spread code with the CIR to realize the signal passing channel

Rake receiver

To use Rake receiver, we must have a good channel estimation.In this demo, we assume we know this channel very well. We have 3 fingers in this Rake receiver.

%Rake receiver design

% finger 1 ( no delay)branch1=reshape(receive_n(1:Nd*Lc),Lc,Nd);correlation1=code*branch1*(1/channel(1));ideal=sign(correlation1);

% finger 2 ( delay1)branch2=reshape(receive_n(delay1+1:delay1+Nd*Lc), Lc,Nd);correlation2=code*branch2*(1/channel(delay1+1));

% finger 3 ( delay2)branch3=reshape(receive_n(delay2+1:delay2+Nd*Lc), Lc,Nd);correlation3=code*branch3*(1/channel(delay2+1));

Note:Here we use correlation in each finger.With perfect knowledge of channel, we can eliminate the effects introduced by the channel.Due to the delay, we choose different start points for each finger.

CombinationWe will calculate the weight for each finger and combine them toget the result.

Calculate the weighta1=norm(correlation1)^2 / (norm(correlation1)^2 +

norm(correlation2)^2 + norm(correlation3)^2);a2=norm(correlation2)^2 / (norm(correlation1)^2 +

norm(correlation2)^2+norm(correlation3)^2);a3=norm(correlation3)^2 / (norm(correlation1)^2 +

norm(correlation2)^2+norm(correlation3)^2);

Combination result=sign(a1*correlation1+a2*correlation2+a3*correlation3);

Simulation result

% initialization

Nd=1000; % source lengthchlength=2:2:16;

SNR=0:2:20;loop=1000; % Monte carlo SimulationRate=zeros(1,length(SNR)); % Predefine error ratecolor=['b','r','m','g','y',':','k','c'];for i=1:length(chlength)

Lg=chlength(i);for dB=1:length(SNR)

for lp=1:loop % loop for Monte Carlo Simulation

% sourcesource=sign(rand(1,Nd)-0.5);

source_in_dB=10*log10(std(source)^2);noise_in_dB=source_in_dB-SNR;

% rand Uniformly distributed random numbers

% channel model1ch=randn(1,Lg)/10;ch(1)=1;ch=ch/norm(ch);

% channel model2ch=randn(1,Lg);ch=ch/norm(ch);

% randn Normally distributed random numbers

% passed channelout=conv(ch,source);

n=wgn(size(out,1),size(out,2),noise_in_dB(dB));out_n=out+n;

% wgn Generate white Gaussian noise% awgn Add white Gaussian noise to a signal% size M = size(X,DIM) returns the length of the

dimension specified by the scalar DIM% Receiver

result=sign(out_n(1:Nd));[err,rate]=symerr(result,source);Rate(dB)=Rate(dB)+rate;endRate(dB)=Rate(dB)/loop;

end