update pam 6
This commit is contained in:
@@ -14,9 +14,10 @@ classdef PAMmapper
|
||||
% Detailed explanation goes here
|
||||
obj.M = M;
|
||||
obj.unipolar = unipolar;
|
||||
|
||||
|
||||
obj.thresholds = obj.get_demodulation_thresholds();
|
||||
|
||||
|
||||
end
|
||||
|
||||
function out = map(obj,signal_in)
|
||||
@@ -39,7 +40,7 @@ classdef PAMmapper
|
||||
|
||||
function pam_sig = map_(obj,bitpattern)
|
||||
|
||||
switch log2(obj.M)
|
||||
switch obj.M
|
||||
case 1
|
||||
% 2-ASK: BPSK / OOK
|
||||
pam_sig=bitpattern(:,1);
|
||||
@@ -48,7 +49,7 @@ classdef PAMmapper
|
||||
pam_sig=2*pam_sig-1;
|
||||
end
|
||||
|
||||
case 2
|
||||
case 4
|
||||
% 4-ASK:
|
||||
pam_sig=2*bitpattern(:,1)+(bitpattern(:,1)==bitpattern(:,2));
|
||||
|
||||
@@ -58,8 +59,21 @@ classdef PAMmapper
|
||||
|
||||
pam_sig = pam_sig .* 1/sqrt(5);
|
||||
|
||||
case 6
|
||||
|
||||
m = 1;
|
||||
if size(bitpattern,2)>size(bitpattern,1)
|
||||
bitpattern = bitpattern'; %vector aufrecht stellen
|
||||
end
|
||||
% LUT based mapping
|
||||
for k = 1:5:fix(length(bitpattern)/5)*5
|
||||
pam_sig(m:m+1,1) = obj.thresholds(bin2dec(int2str(bitpattern(k:k+4)'))+1,:);
|
||||
m = m+2;
|
||||
end
|
||||
|
||||
case 3
|
||||
pam_sig = pam_sig/sqrt(10);
|
||||
|
||||
case 8
|
||||
% 8-ASK:
|
||||
x1 = bitpattern(:,1);
|
||||
x2 = (bitpattern(:,1)==bitpattern(:,3));
|
||||
@@ -72,7 +86,7 @@ classdef PAMmapper
|
||||
end
|
||||
|
||||
|
||||
case 4
|
||||
case 16
|
||||
% 16-ASK:
|
||||
x1 = bitpattern(:,1);
|
||||
x2 = (bitpattern(:,1)==bitpattern(:,4));
|
||||
@@ -94,9 +108,9 @@ classdef PAMmapper
|
||||
%28.03.2023 - Silas Oett. - Extracted from digi_demod.m
|
||||
%
|
||||
|
||||
switch log2(obj.M)
|
||||
switch obj.M
|
||||
|
||||
case 1
|
||||
case 2
|
||||
% 2-ASK
|
||||
|
||||
if obj.unipolar
|
||||
@@ -105,7 +119,7 @@ classdef PAMmapper
|
||||
thres=0;
|
||||
end
|
||||
|
||||
case 2
|
||||
case 4
|
||||
% 4-ASK
|
||||
if obj.unipolar==0
|
||||
thres=[-2,0,2];
|
||||
@@ -114,7 +128,11 @@ classdef PAMmapper
|
||||
end
|
||||
thres = thres .* 1/sqrt(5);
|
||||
|
||||
case 3
|
||||
case 6 %PAM 6
|
||||
|
||||
thres = [-3 5;-1 5;-3 -5;-1 -5;-5 3;-5 1;-5 -3;-5 -1;-1 3;-1 1;-1 -3;-1 -1;-3 3;-3 1;-3 -3;-3 -1;3 5;1 5;3 -5;1 -5;5 3;5 1;5 -3;5 -1;1 3;1 1;1 -3;1 -1;3 3;3 1;3 -3;3 -1];
|
||||
|
||||
case 8
|
||||
% 8-ASK
|
||||
if obj.unipolar==0
|
||||
thres=-6:2:6;
|
||||
@@ -122,7 +140,7 @@ classdef PAMmapper
|
||||
thres=0.5:6.5;
|
||||
end
|
||||
|
||||
case 4
|
||||
case 16
|
||||
% 16-ASK
|
||||
if obj.unipolar==0 && scale_mode==1
|
||||
thres=-14:2:14;
|
||||
@@ -135,44 +153,67 @@ classdef PAMmapper
|
||||
end
|
||||
|
||||
function [data_out] = demap_(obj,data_in)
|
||||
|
||||
data_in= data_in';
|
||||
% create output
|
||||
if ~isempty(obj.thresholds)
|
||||
a = squeeze(repmat(real(data_in),[1 1 length(obj.thresholds)])); %Eingangssignal in 3 spalten
|
||||
b = squeeze(repmat(reshape(obj.thresholds(:).',[1 1 length(obj.thresholds)]),[1 length(data_in) 1])); %Threshold in 3 Spalten
|
||||
comp_real = a > b; %check for each symbol/ sampling if it exeeds the obj.thresholdseshold 1, 2 or 3
|
||||
|
||||
comp_real=repmat(real(data_in),[1 1 length(obj.thresholds)]) > repmat(reshape(obj.thresholds(:).',[1 1 length(obj.thresholds)]),[1 length(data_in) 1]);
|
||||
|
||||
else
|
||||
comp_real=[];
|
||||
if obj.M ~= 6
|
||||
|
||||
% create output
|
||||
if ~isempty(obj.thresholds)
|
||||
a = squeeze(repmat(real(data_in),[1 1 length(obj.thresholds)])); %Eingangssignal in 3 spalten
|
||||
b = squeeze(repmat(reshape(obj.thresholds(:).',[1 1 length(obj.thresholds)]),[1 length(data_in) 1])); %Threshold in 3 Spalten
|
||||
comp_real = a > b; %check for each symbol/ sampling if it exeeds the obj.thresholdseshold 1, 2 or 3
|
||||
|
||||
comp_real=repmat(real(data_in),[1 1 length(obj.thresholds)]) > repmat(reshape(obj.thresholds(:).',[1 1 length(obj.thresholds)]),[1 length(data_in) 1]);
|
||||
|
||||
else
|
||||
comp_real=[];
|
||||
end
|
||||
|
||||
s1=size(comp_real,1);
|
||||
s2=size(comp_real,2);
|
||||
end
|
||||
|
||||
s1=size(comp_real,1);
|
||||
s2=size(comp_real,2);
|
||||
switch obj.M
|
||||
|
||||
|
||||
switch log2(obj.M)
|
||||
|
||||
case 1
|
||||
case 2
|
||||
% 2-ASK
|
||||
|
||||
data_out=comp_real(:,:,1);
|
||||
|
||||
case 2
|
||||
case 4
|
||||
% 4-ASK
|
||||
|
||||
data_out=[comp_real(:,:,2); ones(s1,s2) - comp_real(:,:,1) + comp_real(:,:,3)];
|
||||
|
||||
case 6
|
||||
|
||||
case 3
|
||||
data_in = data_in/(sqrt(mean(abs(data_in).^2)));
|
||||
data_in = data_in*sqrt(10);
|
||||
|
||||
if size(data_in,2) > 1
|
||||
data_in = data_in.';
|
||||
end
|
||||
|
||||
if length(data_in)/2 ~= round(length(data_in)/2)
|
||||
data_in = [data_in;0];
|
||||
end
|
||||
|
||||
m = 1;
|
||||
for n = 1:2:length(data_in)
|
||||
dist = sqrt((data_in(n)-obj.thresholds(:,1)).^2+(data_in(n+1)-obj.thresholds(:,2)).^2);
|
||||
[~,dd_idx] = min(dist);
|
||||
% dec_out(n:n+1) = LUT(dd_idx,:);
|
||||
data_out(m:m+4) = bitget(dd_idx-1,5:-1:1);
|
||||
m = m+5;
|
||||
end
|
||||
|
||||
|
||||
case 8
|
||||
% 8-ASK
|
||||
data_out=[comp_real(:,:,4);
|
||||
comp_real(:,:,1)-comp_real(:,:,3)+comp_real(:,:,5)-comp_real(:,:,7);
|
||||
1-comp_real(:,:,2)+comp_real(:,:,6)];
|
||||
|
||||
case 4
|
||||
case 16
|
||||
% 16-ASK
|
||||
data_out=[comp_real(:,:,8);
|
||||
comp_real(:,:,1)-comp_real(:,:,3)+comp_real(:,:,5)-comp_real(:,:,7)+comp_real(:,:,9)-comp_real(:,:,11)+comp_real(:,:,13)-comp_real(:,:,15);
|
||||
|
||||
Reference in New Issue
Block a user