Commit cae6a9740517e23d2c437b24d454920181d4f82e

Authored by Yujen Ku
1 parent fcf9ba9224
Exists in master

add credit

Showing 1 changed file with 8 additions and 2 deletions Inline Diff

1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2 % Code file provided from ECE 257B SP2018 %
3 % Instructor: Dinesh Bharadia, Manu Seth %
4 % Department of Electrical and Computer Engineering, %
5 % University in San Diego, California, USA %
6 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7
function [map_out]=mapping(data,mode,scale) 1 8 function [map_out]=mapping(data,mode,scale)
2 9
% mode : Modulation order in power of 2 (1/2/4/6 = BSPK/QPSK/16-QAM/64-QAM) 3 10 % mode : Modulation order in power of 2 (1/2/4/6 = BSPK/QPSK/16-QAM/64-QAM)
% scale : scaling up or down the modulation, default value = 1 4 11 % scale : scaling up or down the modulation, default value = 1
5 12
input_seq = data; 6 13 input_seq = data;
7 14
switch mode 8 15 switch mode
case 1 9 16 case 1
b=scale*[1 -1]; 10 17 b=scale*[1 -1];
case 2 11 18 case 2
b=scale*[1+1i -1+1i 1-1i -1-1i]; 12 19 b=scale*[1+1i -1+1i 1-1i -1-1i];
case 4 13 20 case 4
b=scale*[1+1i 1+3i 1-1i 1-3i 3+1i 3+3i 3-1i 3-3i -1+1i -1+3i -1-1i -1-3i -3+1i -3+3i -3-1i -3-3i]; 14 21 b=scale*[1+1i 1+3i 1-1i 1-3i 3+1i 3+3i 3-1i 3-3i -1+1i -1+3i -1-1i -1-3i -3+1i -3+3i -3-1i -3-3i];
case 6 15 22 case 6
b=scale*[3+3i 3+1i 3+5i 3+7i 3-3i 3-1i 3-5i 3-7i 1+3i 1+1i 1+5i 1+7i 1-3i 1-1i 1-5i 1-7i 5+3i 5+1i 5+5i 5+7i 5-3i 5-1i 5-5i 5-7i 7+3i 7+1i 7+5i 7+7i 7-3i 7-1i 7-5i 7-7i -3+3i -3+1i -3+5i -3+7i -3-3i -3-1i -3-5i -3-7i -1+3i -1+1i -1+5i -1+7i -1-3i -1-1i -1-5i -1-7i -5+3i -5+1i -5+5i -5+7i -5-3i -5-1i -5-5i -5-7i -7+3i -7+1i -7+5i -7+7i -7-3i -7-1i -7-5i -7-7i]; 16 23 b=scale*[3+3i 3+1i 3+5i 3+7i 3-3i 3-1i 3-5i 3-7i 1+3i 1+1i 1+5i 1+7i 1-3i 1-1i 1-5i 1-7i 5+3i 5+1i 5+5i 5+7i 5-3i 5-1i 5-5i 5-7i 7+3i 7+1i 7+5i 7+7i 7-3i 7-1i 7-5i 7-7i -3+3i -3+1i -3+5i -3+7i -3-3i -3-1i -3-5i -3-7i -1+3i -1+1i -1+5i -1+7i -1-3i -1-1i -1-5i -1-7i -5+3i -5+1i -5+5i -5+7i -5-3i -5-1i -5-5i -5-7i -7+3i -7+1i -7+5i -7+7i -7-3i -7-1i -7-5i -7-7i];
otherwise 17 24 otherwise
error('wrong choice'); 18 25 error('wrong choice');
end 19 26 end
20 27
count=1; 21 28 count=1;
map_out = zeros(1,ceil(length(input_seq)/mode)); 22 29 map_out = zeros(1,ceil(length(input_seq)/mode));
23 30
for i=1:(ceil(length(input_seq)/mode)) 24 31 for i=1:(ceil(length(input_seq)/mode))
temp=0; 25 32 temp=0;
for j=1:mode 26 33 for j=1:mode
temp=bitor(temp,bitshift(input_seq(count),(j-1))); 27 34 temp=bitor(temp,bitshift(input_seq(count),(j-1)));
count=count+1; 28 35 count=count+1;
if(count>length(input_seq)) 29 36 if(count>length(input_seq))