decision device in BASK receiver

I'm designing decision device in BASK receiver and i have total no. of symbols ns=3000 and divided into total number of bits (tnb)=30 and each bit contains (nsb=100) samples.. i want to make nested for loops that add each 100 sample in each bit and divide it by the total no. of samples (nsb) to get average, if the sum greater than 0.5 then the output is 1 else 0 !!! i made the following code but it's wrong
for w=1:nsb:ns
summ=0;
for g=1:nsb
summ= (summ+fds(g))/nsb
if summ <= 0.5
bitout=0;
else
bitout=1;
end
end
end
where fds is the output from the transmitter after the envelope detector
please could anyone help me with this code?? thanks,

 채택된 답변

Walter Roberson
Walter Roberson 2011년 4월 20일

1 개 추천

I suspect that at the very least you want to move your "if" to after the "end" of the "for g". However, I have to been able to tell from your description what you are trying to do. For example, why calculate all those bitout values only to throw them away the next time you go through the loop?

댓글 수: 3

Salma
Salma 2011년 4월 20일
i did a little modification in the code
%ns=3000
%nsb=100
%tnb=30
%fds= output from envelope detector
for w=1:nsb:ns
summ=0;
for g=1:nsb
summ= summ+fds(g);
end
tot= summ/nsb;
if summ <= 0.5
bitout=0
else
bitout=1
end
end
the problem is that in the second for loop it loops only from 1 to 100 (1:nsb) but it doesn't continue from 101 to 200, 201 to 300 and so on.. so do you have any idea how could i solve that??
Walter Roberson
Walter Roberson 2011년 4월 20일
for g = w:w+nsb-1
Salma
Salma 2011년 4월 21일
thanks it works perfectly :)

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by