⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dqam4_eculd.m

📁 QAM 4 Modulator and Demodulator based on ETSI TETRA Standard
💻 M
字号:
% Function for 4 - QAM De-Modulation 
% base on eculidian distance 


function digit = dqam4_eculd(i_dqam)

% disp('Demodulatiuon of 4-QAM');

%disp('input size');
%disp( length(i_dqam) );

dtemp = size(i_dqam) ;
drow  = dtemp(1) ;  %rows 
% dcolm = dtemp(2) ;  %colom
%o_dqam = null;

%database for assign demodelated values
R(1,:) = [ 0 0 ] ;     % 0 
R(2,:) = [ 1 0 ] ;     % 2
R(3,:) = [ 1 1 ] ;     % 3
R(4,:) = [ 0 1 ] ;     % 1


  for k=1:drow   %increment of 1 each time
      %disp(k);
      %getting real and imagnery parts
        realp = real(i_dqam(k) );
        imagp = imag(i_dqam(k) );
      
      %determining the region and corresponding binary using shortest for 16QAM
      %                 . q-axis                     eculidian distance
      %      2          .         0
      %             R2  .  R1   
      % ..............................  i-axis
      %             R3  .  R4   
      %       3         .         1
      %                 .  
      
      %region 01
      if( realp >= 0 && imagp >= 0 ) 
         % disp('region 01');
          d(1) = ( (realp - 1 )^2 + ( imagp - 1 )^2  ) ^ 0.5;   %1+i  15  index 1
%            min_dist =  min(d);
%           %getting the index
%           d=d'; index = find(d==min_dist);
           o_dqam(k,:) = R(1,:);
          %disp(d);
              
      else
          if( realp < 0 && imagp > 0 ) %region 02
          %  disp('region 02');    
             d(2) = ( (realp - (-1) )^2 + ( imagp - 1 )^2  ) ^ 0.5;   %  -1+i   7  index 2
%             min_dist =  min(d);
%             %getting the index
%             d=d'; index = find(d==min_dist);
             o_dqam(k,:) = R(2,:);
            %disp(d);
         else
              if( realp < 0 && imagp < 0 ) %region 03
           %     disp('region 03');  
                d(3) = ( (realp - (-1) )^2 + ( imagp - (-1) )^2  ) ^ 0.5;   %  -1-i    5  index 3 
%                  min_dist =  min(d);
%                 %getting the index
%                 d=d'; index = find(d==min_dist);
%                 %disp(d);disp(index);
                o_dqam(k,:) = R(3,:);
%               
            else %region 4
            %    disp('region 04');
                d(4) = ( (realp - 1 )^2 + ( imagp - (-1) )^2  ) ^ 0.5;   %  1-i    13  index 4
%                 min_dist =  min(d);
%                 %getting the index
%                 d=d'; index = find(d==min_dist);
%                 %disp(d);disp(index);
                 o_dqam(k,:) = R(4,:);
              end
           end    
      end
       
     digit= bi2de(o_dqam,'left-msb');
end %end of for loop       

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -