BER for BPSK through frequency selective fading channel using rayleighchan function and rls algorithm for adaptive equalizer
7 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
please help me with my project I need to measure the performance evaluation of BPSK through a three path frequency selective fading channel... I search in the help browser of the matlab and I found the following code but it doesn't work correctly.. so if you please help me and I will very thankful clear
clc
close all
k=0;
for EsNodB=27:5:27
s1=RandStream('mrg32k3a','Seed',0);
s4=RandStream('mrg32k3a','Seed',1);
s5=RandStream('mrg32k3a','Seed',2);
errcount=0;
Tsym = 1e-6; % Symbol period (s)
bitsPerSymbol = 1; % Number of bits per BPSK symbol
M = 2.^bitsPerSymbol; % BPSK alphabet size (number of modulation levels)
nPayload = 40; % Number of payload symbols
nTrain = 10; % Number of training symbols
nTail = 20; % Number of tail symbols
hStream = RandStream.create('mt19937ar', 'seed', 12345);
hStream1 = RandStream.create('mt19937ar', 'seed', 12354);
for i=1:1:1
pskmodObj = modem.pskmod(M); % modulator object
xTextSym=randi(s1, [0 M-1], 1, nPayload)
xText = modulate(pskmodObj, xTextSym)
% Training sequence symbols
xTrainSym = randi(hStream, [0 M-1], 1, nTrain);
% Modulated training sequence
xTrain = modulate(pskmodObj, xTrainSym);
% Tail sequence symbols
xTailSym = randi(hStream1, [0 M-1], 1, nTail);
% Modulated tail sequence
xTail = modulate(pskmodObj, xTailSym);
nSymFilt = 8; % Number of symbol periods spanned by each filter
osfFilt = 4; % Oversampling factor for filter (samples per symbol)
rolloff =0.25; % Rolloff factor
Tsamp = Tsym/osfFilt; % TX signal sample period (s)
orderFilt = nSymFilt*osfFilt; % Filter order (number of taps - 1) % Filter responses and structures
hTxFilt = fdesign.interpolator(osfFilt, 'Square Root Raised Cosine', ... osfFilt, 'N,Beta', orderFilt, rolloff)
hRxFilt = fdesign.decimator(osfFilt, 'Square Root Raised Cosine', ... osfFilt, 'N,Beta', orderFilt, rolloff)
hDTxFilt = design(hTxFilt)
hDRxFilt = design(hRxFilt)
hDTxFilt.PersistentMemory = true; hDRxFilt.PersistentMemory = true;
% Multipath channel
fd = 0; % Maximum Doppler shift (Hz)
chan = rayleighchan(Tsamp, fd); % Create channel object.
chan.PathDelays = [0 0.4 0.9 ]*Tsym; % Path delay vector (s)
chan.AvgPathGaindB = [0 -15 -20]; % Average path gain vector (dB)
chan.ResetBeforeFiltering = 0; % Allow state retention across blocks.
delay = chan.ChannelFilterDelay
%simName = 'Linear equalization for frequency-selective fading';
ri=filter(chan,xText)
rx=filter(chan,xTrain)
snrdB = EsNodB - 10*log10(osfFilt); % Signal-to-noise ratio per sample (dB)
%n = randn(s4,1,nPayload) + 1i*randn(s5,1,nPayload); % white gaussian noise, 0dB variance
n = randn(s4,1,nPayload); % white gaussian noise, 0dB variance
std=sqrt(10^(-snrdB/10));
ni=std*n;
%ri1=ri+ni;
% Adaptive equalizer
nWeights = 8;
forgetFactor = 0.99; % RLS algorithm forgetting factor
alg = rls(forgetFactor); % RLS algorithm object
eqObj = lineareq(nWeights, alg) % Equalizer object
eqObj.RefTap = 3; % Reference tap
y = equalize(eqObj,ri,rx)
%disp('y');disp(y);
pskdmodObj = modem.pskdemod(M);
y1 = demodulate(pskdmodObj, y)
%y1 = real(y)>0;
disp('y1');disp(y1);
%nErr = size(find(xTextSym- y1),2);
%for j=1:1:100 % if y1(j)~=xTextSym(j) % errcount=errcount+1; % end % end
%errcount=errcount+nErr;
%reset(pskmodObj); %reset(pskdmodObj); % Compute bit error rate, taking delay into account. % Truncate to account for channel delay.
xTextSym_trunc = xTextSym(1:end-delay); y1_trunc = y1(delay+1:end);
[num,ber] = biterr(xTextSym_trunc,y1_trunc) % Bit error rate
errcount=errcount+ber;
end
k=k+1;
%BER(k)=ber
BER(k)=(errcount/1)
theoryBerAWGN(k) = 0.5*erfc(sqrt(10^(snrdB/10))) % theoretical ber
%EbN0Lin = 10^(snrdB/10);
%theoryBer(k) = 0.5*(1-sqrt(EbN0Lin/(EbN0Lin+1)))
theoryBer(k) = berfading(snrdB,'dpsk',M,1)
snr(k) =snrdB
end
figure
%semilogy(snr,theoryBerAWGN,'cd-','LineWidth',2);
%hold on
semilogy(snr,theoryBer,'bp-','LineWidth',2);
hold on
semilogy(snr,BER,'mx-','LineWidth',2);
grid on
legend('Rayleigh-Theory', 'Rayleigh-Simulation');
%legend('AWGN-Theory','Rayleigh-Theory', 'Rayleigh-Simulation');
xlabel('Eb/No, dB');
ylabel('Bit Error Rate');
title('BER for BPSK modulation in Rayleigh channel');
grid on
1 comentario
Respuestas (1)
shaik
el 19 de En. de 2014
clc
close all
k=40;
for EsNodB=1:k
s1=RandStream('mrg32k3a','Seed',0);
s4=RandStream('mrg32k3a','Seed',1);
s5=RandStream('mrg32k3a','Seed',2);
errcount=0;
Tsym = 1e-6; % Symbol period (s)
bitsPerSymbol = 1; % Number of bits per BPSK symbol
M = 2.^bitsPerSymbol; % BPSK alphabet size (number of modulation levels)
nPayload = 40; % Number of payload symbols
nTrain = 10; % Number of training symbols
nTail = 20; % Number of tail symbols
hStream = RandStream.create('mt19937ar', 'seed', 12345);
hStream1 = RandStream.create('mt19937ar', 'seed', 12354);
for i=1:1:1
pskmodObj = modem.pskmod(M); % modulator object
xTextSym=randi(s1, [0 M-1], 1, nPayload)
xText = modulate(pskmodObj, xTextSym)
% Training sequence symbols
xTrainSym = randi(hStream, [0 M-1], 1, nTrain);
% Modulated training sequence
xTrain = modulate(pskmodObj, xTrainSym);
% Tail sequence symbols
xTailSym = randi(hStream1, [0 M-1], 1, nTail);
% Modulated tail sequence
xTail = modulate(pskmodObj, xTailSym);
nSymFilt = 8; % Number of symbol periods spanned by each filter
osfFilt = 4; % Oversampling factor for filter (samples per symbol)
rolloff =0.25; % Rolloff factor
Tsamp = Tsym/osfFilt; % TX signal sample period (s)
orderFilt = nSymFilt*osfFilt; % Filter order (number of taps - 1) % Filter responses and structures
hTxFilt = fdesign.interpolator(osfFilt, 'Square Root Raised Cosine', osfFilt, 'N,Beta', orderFilt, rolloff)
hRxFilt = fdesign.decimator(osfFilt, 'Square Root Raised Cosine',osfFilt, 'N,Beta', orderFilt, rolloff)
hDTxFilt = design(hTxFilt)
hDRxFilt = design(hRxFilt)
hDTxFilt.PersistentMemory = true; hDRxFilt.PersistentMemory = true;
% Multipath channel
fd = 0; % Maximum Doppler shift (Hz)
chan = rayleighchan(Tsamp, fd); % Create channel object.
chan.PathDelays = [0 0.4 0.9 ]*Tsym; % Path delay vector (s)
chan.AvgPathGaindB = [0 -15 -20]; % Average path gain vector (dB)
chan.ResetBeforeFiltering = 0; % Allow state retention across blocks.
delay = chan.ChannelFilterDelay
%simName = 'Linear equalization for frequency-selective fading';
ri=filter(chan,xText)
rx=filter(chan,xTrain)
snrdB = EsNodB - 10*log10(osfFilt); % Signal-to-noise ratio per sample (dB)
n = randn(s4,1,nPayload) + 1i*randn(s5,1,nPayload); % white gaussian noise, 0dB variance
n = randn(s4,1,nPayload); % white gaussian noise, 0dB variance
std=sqrt(10^(-snrdB/10));
ni=std*n;
ri1=ri+ni;
% Adaptive equalizer
nWeights = 8;
forgetFactor = 0.99; % RLS algorithm forgetting factor
alg = rls(forgetFactor); % RLS algorithm object
eqObj = lineareq(nWeights, alg) % Equalizer object
eqObj.RefTap = 3; % Reference tap
y = equalize(eqObj,ri,rx)
disp('y');disp(y);
pskdmodObj = modem.pskdemod(M);
y1 = demodulate(pskdmodObj, y)
y1 = real(y)>0;
disp('y1');disp(y1);
nErr = size(find(xTextSym- y1),2);
for j=1:1:40 if y1(j)~=xTextSym(j) errcount=errcount+1; end end
errcount=errcount+nErr;
reset(pskmodObj); reset(pskdmodObj); % Compute bit error rate, taking delay into account. % Truncate to account for channel delay.
xTextSym_trunc = xTextSym(1:end-delay); y1_trunc = y1(delay+1:end);
[num,ber] = biterr(xTextSym_trunc,y1_trunc) % Bit error rate
errcount=errcount+ber;
end
k=k+1;
BER(k)=ber
BER(k)=(errcount/1)
theoryBerAWGN(k) = 0.5*erfc(sqrt(10^(snrdB/10))) % theoretical ber
EbN0Lin = 10^(snrdB/10);
theoryBer(k) = 0.5*(1-sqrt(EbN0Lin/(EbN0Lin+1)))
theoryBer(k) = berfading(snrdB,'dpsk',M,1)
snr(k) =snrdB
end snr figure
semilogy(snr,theoryBerAWGN,'*','LineWidth',2);
hold on
semilogy(snr,theoryBer,'g-*','LineWidth',2);
hold on
semilogy(snr,BER,'r-*','LineWidth',2);
grid on
legend('Rayleigh-Theory', 'Rayleigh-Simulation');
legend('AWGN-Theory','Rayleigh-Theory', 'Rayleigh-Simulation');
xlabel('Eb/No, dB');
ylabel('Bit Error Rate');
title('BER for BPSK modulation in Rayleigh channel');
grid on
this is the coding whose error has been removed
2 comentarios
CHRISTOPHER NWAOGU
el 24 de Sept. de 2016
Line 7 For EsNodB=1:k there is a problem in this line please help
student student
el 10 de Dic. de 2018
I'm trying to obtain the frequency response of rayleigh fading channel that i designed in Matlab. This is the function used to get rayleigh fading channel (rayleighchan), any help.
Ver también
Categorías
Más información sobre Propagation and Channel Models en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!