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 endendber=errorcounter/l;endplot(snr,ber)
i tried to run this prog on matlab and there were lots of errors .. is there an alternate prog .. thanx alot
Best Answer