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

📄 constellation_qam.m

📁 This m file shows constellation for MQAM.
💻 M
字号:
function [vect] = constellation_qam(k)% function [vect] = constellation_qam(k)%% Rectangular signal-space constellations for MQAM%% Copyright (C) Olena Mingaliova, Alexander Konovalenko%% This program is free software; you can redistribute it and/or% modify it under the terms of the GNU General Public License% as published by the Free Software Foundation; either version 2% of the License, or (at your option) any later version.%% This program is distributed in the hope that it will be useful,% but WITHOUT ANY WARRANTY; without even the implied warranty of% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the% GNU General Public License for more details.%% You should have received a copy of the GNU General Public License% along with this program; if not, write to the Free Software% Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.%% http://www.gnu.org/licenses/gpl.html%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% where:%  M = 2^k, k is number of bits per symbol% The output vect is Mx2 matrix%% test:% v=constellation_qam(9);grid on; plot(v(:,1),v(:,2),'x');%%% this function was tested with both MatLab & Octave%step = 2;if k <= 1   disp('ERROR: Incorrect input parameters, k<=1');   returnendM = 2^k;%vect = zeros(M,2);i = 1;if mod(k,2) == 0   vect = zeros(M,2);   sqrtM = 2^(k/2);   xmin = -sqrtM + 1;   xmax = sqrtM - 1;   ymin = -sqrtM + 1;   ymax = sqrtM - 1;   for x = xmin:2:xmax      for y = ymin:2:ymax         vect(i,1) = x;         vect(i,2) = y;         i = i + 1;      end   endelseif k ~= 3   % odd k   square = constellation_qam(k-1); % vector   square_side = 2^((k-1)/2) - 1;   side2 = 2^(k-3)/(square_side + 1);   xmin_sq = min(square(:,1));   ymin_sq = min(square(:,2));   % left rectangular:   xmin = xmin_sq - step*side2;   xmax = xmin + step*(side2 - 1);   ymin = ymin_sq;   ymax = ymin + step*square_side;      left = zeros(square_side,2);   right = left;   down = left;   up = left;   j = 1;   offset = (square_side + side2 + 1)*step;   for x = xmin:step:xmax      for y = ymin:step:ymax         left(j,1) = x;         left(j,2) = y;	 right(j,1) = x + offset;         right(j,2) = y;         up(j,1) = y;	 up(j,2) = x + offset;         down(j,1) = y;         down(j,2) = x;         j = j + 1;      end   end   vect = [left; square; right; up; down];else   vect = [-3 1; -3 -1; -1 1; -1 -1; 1 1; 1 -1; 3 1; 3 -1];endvect = sortrows(vect,2);

⌨️ 快捷键说明

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