Effacer les filtres
Effacer les filtres

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

2 vues (au cours des 30 derniers jours)
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 commentaires
mary
mary le 20 Déc 2012
could you copy this plz? the issue is that the prog is not even running it is not working .. it is not about the error counter
mary
mary le 20 Déc 2012
it says that the inner dimentions matrix must agree!!

Connectez-vous pour commenter.

Réponse acceptée

Walter Roberson
Walter Roberson le 21 Déc 2012
Your nii is randn(l) and l is 10^4. According to the randn documentation,
r = randn(n) returns an n-by-n matrix containing pseudorandom values drawn from the standard normal distribution.
so nii will be a 10^4 by 10^4 matrix.
You calculate,
stdn=sqrt(10^(-snr/10))
and your snr is [1:15] which is a 1 x 15 matrix, so your stdn will be a 1 x 15 matrix.
Then you have
ni=nni*stdn;
so you are asking to multiply a 10^4 x 10^4 matrix, by a 1 x 15 matrix. What output were you hoping for from the multiplication?
If you had created nii = rand(10^4,1) then you would be multiplying a 10^4 x 1 matrix by a 1 x 15 matrix. The "*" operator is matrix multiplication, which is defined when the two inner dimensions (the second dimension of the first matrix, the first dimension of the second matrix) are the same size. In that case the output would be a 10^4 x 15 matrix. Is that what you were hoping for, to multiply each different random value by each different snr value ?

Plus de réponses (1)

Rick Rosson
Rick Rosson le 21 Déc 2012

Community Treasure Hunt

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

Start Hunting!

Translated by