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