开发者

modem.oqpskmod - converting array of different values to array of 1s and 0s

开发者 https://www.devze.com 2022-12-19 02:24 出处:网络
hi i was doing the following in matlab values = [0;1;0;0;1;0;1;0];% can contain only 0s and 1s h = modem.oqpskmod;

hi i was doing the following in matlab

    values = [0;1;0;0;1;0;1;0];   % can contain only 0s and 1s 
    h = modem.oqpskmod; 
    y = modulate(h, values); 
    g = modem.oqpskdemod(h); 
    z = demodulate(g,y); 
    BER = sum(logical(values(:)-z(:)))/numel(values); % thanks to gnovice!

before calculating the BER, do you think that i have to convert the array z into array of 1s and 0s only... for example, my z may consist of 3s and 0s, then do i have to convert all numbers bigger than 0 to 1s and all 0s unc开发者_JS百科hanged. so that at the end i get the correct comparison for the BER?


This depends on how you want to do the comparison of the input and output. The code I gave you for computing the BER will count any difference between the input and output as an error. So, a value of 3 for an output and a corresponding 1 for an input are counted as different.

If you want to compute the BER in another way, here are a couple more options you could use. Each of these assumes values contains only zeroes and ones:

  • Count any non-zero output value as a 1: In this case, you would use the function LOGICAL to convert any non-zero value of z (i.e. the values 3, 0.5, -1, etc.) to a 1, leaving the values that are exactly zero unchanged:

    BER = sum(values(:)-logical(z(:)))/numel(values);
    
  • Count positive values as 1 and negative values as 0: This solution just uses a comparison operator instead of LOGICAL:

    BER = sum(values(:)-(z(:) > 0))/numel(values);
    

You may also want to try setting the 'OutputType' property of the modem.oqpskdemod object to 'bit' to ensure a binary output. Then you shouldn't have to do anything to z:

...
g = modem.oqpskdemod(h,'OutputType','bit'); 
z = demodulate(g,y);
BER = sum(values(:)-z(:))/numel(values);
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号