📄 qaskdeco.m
字号:
function [msg]=qaskdeco(x,y,m,minmax)
%QASKDECO Decodes QASK mapped signal back to integer symbols.
% MSG = QASKDECO(X, Y, M) decodes the message signal MSG from the
% in-phase component X and quadrature component Y with the M-ary
% number M. M must equals to 2^K with K being an positive integer. The
% minimum and the maximum number are assumed to be the same as the
% output from QASKENCO.
%
% MSG = QASKDECO(X, Y, M, MINMAX) decodes the information where
% the maximum and minimum values of X and Y are given in the MINMAX
% by the form:
% | X_min X_max |
% MINMAX = | |
% | Y_min Y_max |
%
% See also: QASKENCO.
% Wes Wang 10/11/95.
% Copyright (c) 1995-96 by The MathWorks, Inc.
% $Revision: 1.1 $ $Date: 1996/04/01 18:01:44 $
error(nargchk(1,4,nargin));
if (nargin <= 2) | (nargin > 4)
error('Wrong number of input arguments.')
end;
if (nargin == 4)
[i,j]=size(minmax);
if (i ~= 2) | (j ~= 2)
error('The fourth varaible in calling QASKDECO is incorrect.')
end;
if ((minmax(1,2) <= minmax(1,1)) | (minmax(2,2) <= minmax(2,1))) & (m > 2)
disp('Cannot process QASKDECO')
disp('The fourth variable should have the format:')
disp(' | X_min X_max |')
disp(' | Y_min Y_max |')
end;
if m > 2
x = (x - minmax(1,1))/(minmax(1,2) - minmax(1,1));
end
if m > 0
y = (y - minmax(2,1))/(minmax(2,2) - minmax(2,1));
end;
if (m == 2)
y = y * 2 - 1;
elseif (m == 4)
x = x * 2 - 1;
y = y * 2 - 1;
elseif (m == 8) | (m == 16)
x = x * 6 - 3;
y = y * 6 - 3;
elseif (m == 32)
x = x * 10 - 5;
y = y * 10 - 5;
elseif (m == 64)
x = x * 14 - 7;
y = y * 14 - 7;
elseif (m == 128)
x = x * 22 - 11;
y = y * 22 - 11;
elseif (m == 256)
x = x * 30 - 11;
y = y * 30 - 11;
else
error('M-ary number for QASKDECO must be 2, 4, 8, 16, 32, 64, 128, or 256')
end;
end;
inx = find(x<=0);
if ~isempty(inx)
x(inx) = abs(x(inx)) + 1;
end;
iny = find(y<=0);
if ~isempty(iny)
y(iny) = abs(y(iny)) + 1;
end;
tab = [ 1, 2, 9, 10, 17, 18, 49, 50, 97, 98,113,114,145,146,177,178
3, 4, 11, 12, 19, 20, 51, 52, 99,100,115,116,147,148,179,180
5, 6, 13, 14, 21, 22, 53, 54,101,102,117,118,149,150,181,182
7, 8, 15, 16, 23, 24, 55, 56,103,104,119,120,151,152,183,184
25, 26, 29, 30, 33, 34, 37, 38,105,106,121,122,153,154,185,186
27, 28, 31, 32, 35, 36, 39, 40,107,108,123,124,155,156,187,188
57, 58, 61, 62, 41, 42, 45, 46,109,110,125,126,157,158,189,190
59, 60, 63, 64, 43, 44, 47, 48,111,112,127,128,159,160,191,192
65, 66, 69, 70, 73, 74, 77, 78,129,130,133,134,161,162,193,194
67, 68, 71, 72, 75, 76, 79, 80,131,132,135,136,163,164,195,196
81, 82, 85, 86, 89, 90, 93, 94,137,138,141,142,165,166,197,198
83, 84, 87, 88, 91, 92, 95, 96,139,140,143,144,167,168,199,200
209,210,217,218,225,226,233,234,241,242,249,250,169,170,201,202
211,212,219,220,227,228,235,236,243,244,251,252,171,172,203,204
213,214,221,222,229,230,237,238,245,246,253,254,173,174,205,206
215,216,223,224,231,232,239,240,247,248,255,256,175,176,207,208];
if (m=='fetch')
msg=tab(1:x,1:y);
else
[x_m, x_n] = size(x);
[y_m, y_n] = size(y);
if min(x_m, x_n) * min(y_m, y_n) ~= 1
error('Input X and Y must be vectors.');
end;
for i = 1 : min(length(x), length(y));
msg(i) = tab(x(i), y(i));
end;
if x_m > x_n
msg = msg';
end;
end;
msg = msg - 1;
%---end qaskdeco.m--
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -