fsk modulator and demodulator

3 ビュー (過去 30 日間)
Salma
Salma 2011 年 4 月 21 日
i have this code and although i added noise to it the bit error rate is still zero.. any clue?!!
%%%%%%%%%%%%%fsk mod and demod%%%%%%%%%%%%%%%%%%%%
M = 2;
k = log2(M);
EbNo = 5;
Fs = 16;
nsamp = 17;
freqsep = 8;
n=100;
msg = randint(n,1,M); % Random signal
txsig = fskmod(msg,M,freqsep,nsamp,Fs); % Modulate.
ab=abs(txsig);
ps=(sum(ab.^2))/n;
snr=30;
pn=10.^(-0.1.*snr).*ps;
noise= sqrt(pn)*randn(1,n);
G1=randn(1,n); %generation of Gaussian noise
G2=randn(1,n);
v= sqrt(power(G1,2)+ power(G2,2));
A=v(2);
theta=2*pi*rand;
msg_rx = A*exp(j*theta)*txsig + noise(3); %flat fading
msg_rrx = fskdemod(msg_rx,M,freqsep,nsamp,Fs); % Demodulate
[num,BER] = biterr(msg,msg_rrx) % Bit error rate
BER_theory = berawgn(EbNo,'fsk',M,'noncoherent') % Theoretical BER

採用された回答

Rob Graessle
Rob Graessle 2011 年 4 月 22 日
Walter is right - when you add noise(3) to the signal you are not actually adding random noise, you're just adding some positive or negative shift. Also, the noise vector you are generating is too short.
You can try out the code below (with the changes commented). When you run it several times, you will see that the BER average is close to the theoretical BER of 0.1029.
M = 2;
k = log2(M);
EbNo = 5;
Fs = 16;
nsamp = 17;
freqsep = 8;
n=100;
msg = randint(n,1,M);
txsig = fskmod(msg,M,freqsep,nsamp,Fs);
ab=abs(txsig);
ps=(sum(ab.^2))/n;
snr=5; % Changed this to match EbNo above
pn=10.^(-0.1.*snr).*ps;
noise= sqrt(pn)*randn(1,n*nsamp); % Changed the length of the noise vector from n to n*nsamp
G1=randn(1,n); % You are not generating noise here, you are generating fading coefficients
G2=randn(1,n);
v= sqrt(power(G1,2)+ power(G2,2));
A=v(2);
theta=2*pi*rand;
% I got rid of fading to make sure code works for AWGN case
msg_rx = txsig + noise'; % txsig is 1700x1 and noise is 1x1700, so need transpose
msg_rrx = fskdemod(msg_rx,M,freqsep,nsamp,Fs);
[num,BER] = biterr(msg,msg_rrx) % Bit error rate
BER_theory = berawgn(EbNo,'fsk',M,'noncoherent') % Theoretical BER
  1 件のコメント
Salma
Salma 2011 年 4 月 29 日
I did some modification in the code to plot the graph of snr vs ber with fading but it is wrong, any idea how to fix it??
clear all;clf;clc;close all;
M = 2; k = log2(M); EbNo = 5; Fs = 16; nsamp = 17; freqsep = 8; n=10000;
msg = randint(n,1,M); txsig = fskmod(msg,M,freqsep,nsamp,Fs);
ab=abs(txsig); ps=(sum(ab.^2))/n;
for snr=1:30 pn=10.^(-0.1.*snr).*ps; noise= sqrt(pn)*randn(1,n*nsamp);
G1=randn(1,n); %generating fading coefficients
G2=randn(1,n); v= sqrt(power(G1,2)+ power(G2,2)); A=v(2); theta=2*pi*rand;
alph=A*exp(j*theta); msg_rx = alph*txsig + noise'; % txsig is 1700x1 and noise is 1x1700, so need transpose msg_rxx=msg_rx.*(1/A)*conj(alph); msg_rrx = fskdemod(msg_rxx,M,freqsep,nsamp,Fs);
[num,BER] = biterr(msg,msg_rrx); % Bit error rate
w(snr)=BER;
end
d=[1:30]; figure semilogy(d,w)

サインインしてコメントする。

その他の回答 (1 件)

Walter Roberson
Walter Roberson 2011 年 4 月 21 日
You calculate v=sqrt(G1.^2+G2.^2) where G1 and G2 are 1 x n. You then take v(2) and throw away the rest of v. What is the point of doing all of that, when you could just do
A = sqrt(randn^2+randn^2);
This hints that you are doing something wrong. As does the fact that you use only noise(3) when noise is 1 x n .
You need to check out the magnitude of noise(3) and compare it to the magnitude of A*exp(j*theta)*txsig -- if noise(3) is very small then it would be as if you had not added the noise, merely phase-shifted the signal.
  4 件のコメント
Salma
Salma 2011 年 4 月 21 日
i chose noise(3) randomly i don't care about the value i just did that so i could test the code if it works with noise so when you told me compare the magnitudes i chose the largest value which is noise(17) to see if it makes any difference in the BER but it doesn't so do you think i code have error in the noise code itself??
Salma
Salma 2011 年 4 月 29 日
I did some modification in the code to plot the graph of snr vs ber with fading but it is wrong, any idea how to fix it??
clear all;clf;clc;close all;
M = 2; k = log2(M); EbNo = 5; Fs = 16; nsamp = 17; freqsep = 8; n=10000;
msg = randint(n,1,M); txsig = fskmod(msg,M,freqsep,nsamp,Fs);
ab=abs(txsig); ps=(sum(ab.^2))/n;
for snr=1:30 pn=10.^(-0.1.*snr).*ps; noise= sqrt(pn)*randn(1,n*nsamp);
G1=randn(1,n); %generating fading coefficients
G2=randn(1,n); v= sqrt(power(G1,2)+ power(G2,2)); A=v(2); theta=2*pi*rand;
alph=A*exp(j*theta); msg_rx = alph*txsig + noise'; % txsig is 1700x1 and noise is 1x1700, so need transpose msg_rxx=msg_rx.*(1/A)*conj(alph); msg_rrx = fskdemod(msg_rxx,M,freqsep,nsamp,Fs);
[num,BER] = biterr(msg,msg_rrx); % Bit error rate
w(snr)=BER;
end
d=[1:30]; figure semilogy(d,w)

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeFSK についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by