www.pudn.com > ldpc802.16.rar > qamdemod16soft.m, change:2005-11-15,size:2238b


function [data_sym]=qamdemod4(data_in,scale,sigma) 
 
map_table=[-3 + 3i,-3 + 1i,-3 - 3i,-3 - 1i,-1 + 3i,-1 + 1i,-1 - 3i,-1 - 1i,3 + 3i,3 + 1i,3 - 3i,3 - 1i,1 + 3i,1 + 1i,1 - 3i,1 - 1i]*sqrt(1/10); 
%                   0         1         2        3         4         5         6        7       8        9       10     11     12      13      14     15 
%                0000    0001   0010   0011    0100   0101   0110   0111  1000   1001  1010  1011 1100  1101   1110  1111  
 
len=length(data_in); 
var=1*sigma; 
 
tmp=zeros(1,4*len); 
for k=1:len 
    r=data_in(k); 
     
    for j=1:length(map_table) 
        d(j)=abs(r-scale*map_table(j)).^2; 
    end 
     
    % the first bit 
    D1_1=0;D1_0=0; 
    for i=1:8 
        D1_1=D1_1+exp(-d(i+8)/var); 
        D1_0=D1_0+exp(-d(i)/var); 
    end 
    if (D1_1==0)&(D1_0==0) 
        for i=1:8 
            D1_1=D1_1+exp(-d(i+8)/1e-4); 
            D1_0=D1_0+exp(-d(i)/1e-4); 
        end 
    end 
     
    % the second bit 
    D2_1=0;D2_0=0; 
    for i=5:8 
        D2_1=D2_1+exp(-d(i)/var)+exp(-d(i+8)/var); 
        D2_0=D2_0+exp(-d(i-5+1)/var)+exp(-d(i+4)/var); 
    end 
    if (D2_1==0)&(D2_0==0) 
        for i=5:8 
            D2_1=D2_1+exp(-d(i)/1e-4)+exp(-d(i+8)/1e-4); 
            D2_0=D2_0+exp(-d(i-5+1)/1e-4)+exp(-d(i+4)/1e-4); 
        end 
    end 
     
    % the third bit 
    D3_1=0;D3_0=0; 
    for i=3:4:16 
        D3_1=D3_1+exp(-d(i)/var)+exp(-d(i+1)/var); 
        D3_0=D3_0+exp(-d(i-3+1)/var)+exp(-d(i-3+2)/var); 
    end 
    if (D3_1==0)&(D3_0==0) 
        for i=3:4:16 
            D3_1=D3_1+exp(-d(i)/1e-4)+exp(-d(i+1)/1e-4); 
            D3_0=D3_0+exp(-d(i-3+1)/1e-4)+exp(-d(i-3+2)/1e-4); 
        end 
    end 
     
    % the fourth bit 
    D4_1=0;D4_0=0; 
    for i=2:4:16 
        D4_1=D4_1+exp(-d(i)/var)+exp(-d(i+2)/var); 
        D4_0=D4_0+exp(-d(i-2+1)/var)+exp(-d(i+1)/var); 
    end 
    if (D4_1==0)&(D4_0==0) 
        for i=2:4:16 
            D4_1=D4_1+exp(-d(i)/1e-4)+exp(-d(i+1)/1e-4); 
            D4_0=D4_0+exp(-d(i-2+1)/1e-4)+exp(-d(i+2)/1e-4); 
        end 
    end 
     
    tmp(4*k-3)=D1_1/(D1_1+D1_0); 
    tmp(4*k-2)=D2_1/(D2_1+D2_0); 
    tmp(4*k-1)=D3_1/(D3_1+D3_0); 
    tmp(4*k)=D4_1/(D4_1+D4_0); 
end 
 
data_sym=tmp;