how can i write a program that transmits a signal through a AWGN channel .. showing the effect of the noise?? how can i compute bit error rate and signal to noise ration and then plot them togother using matlab
Show older comments
l=10^4; // total number of transmitted bits (no. of si)
errorcounter=0;
snr=[1:15]; // range of signal to noise ratio
nni=randn(l); // the noise before multiplying it by std (standard deviation)
si=[+1 +1 -1 -1 -1 +1 -1 +1]; // my signal (is there a way to create such array without writting the whole elements like i did?)
for i=1:15
stdn=sqrt(10^(-snr/10))
ni=nni*stdn; // this is the noise that will affect the signal si
ri=ni+si; // my output
if ri>0
sdi=1; //my new array element the final result
elseif ri<=0
sdi=-1;
elseif sdi ~= si then errorcounter=errorcounter+1 // error occured
end
end
ber=errorcounter/l;
end
plot(snr,ber)
i tried to run this prog on matlab and there were lots of errors .. is there an alternate prog .. thanx alot
8 Comments
Rick Rosson
on 20 Dec 2012
Please format your code. Please add comments to the code so we can understand it. Please ask a specific question.
Walter Roberson
on 20 Dec 2012
What is the reason you think the program is not working properly?
mary
on 20 Dec 2012
Walter Roberson
on 20 Dec 2012
What errors do you see? Or do you mean that the errorcounter goes much higher than you expect?
Please do not use // comments on MATLAB code: it prevents people from copying and pasting your code to test it themselves.
mary
on 20 Dec 2012
mary
on 20 Dec 2012
mary
on 20 Dec 2012
Accepted Answer
More Answers (1)
Rick Rosson
on 21 Dec 2012
0 votes
Categories
Find more on MATLAB in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!