?? modulation.m
字號:
function mod_out=modulation(mod_in,mod_mode)
%%*************************************************************************
%%Function information:
%%-------------------------------------------------------------------------
%%First time : 3/25/2002
%%Newest modified time:6/20/2002
%%Programmer:Xuewei Mao
%%Version: 0.2
%%-------------------------------------------------------------------------
%%*************************************************************************
%%*************************************************************************
%% Reference:
%%-------------------------------------------------------------------------
%%
%%-------------------------------------------------------------------------
%% Note:
%%-------------------------------------------------------------------------
%%
%%-------------------------------------------------------------------------
%% Function discription:
%%-------------------------------------------------------------------------
%%根據輸入的調制方式,對輸入序列MOD_IN進行調制,分別采用BPSK, QPSK, !6QAM, 64QAM,
%%完成對星座圖的映射,輸出為Y.轉化的方法為:先寫出十進制情況下從0 到N-1
%%(N為星座圖的點數)所對應的星座坐標;再將輸入的二進制序列轉化為相應的
%%十進制,以查表的方法查出對應點的復數坐標,即為調制映射后的結果。
%%The OFDM subcarriers shall be modulated by using BPSK, QPSK, 16-QAM, or 64-QAM modulation,
%%depending on the RATE requested. The encoded and interleaved binary serial input data shall
%%be divided into groups of N BPSC (1, 2, 4, or 6) bits and converted into complex numbers
%%representing BPSK, QPSK, 16-QAM, or 64-QAM constellation points. The conversion shall be
%%performed according to Gray-coded constellation mappings, with the input bit MOD_IN. The
%%output values,MOD_OUT are formed by multiplying the resulting (I+jQ) value by a normalization
%%factor K MOD , as described in equation d = (I + jQ) × K MOD ) The normalization factor,K MOD,
%%depends on the base modulation mode. Note that the modulation type can be different from the
%%start to the end of the transmission, as the signal changes from SIGNAL to DATA. The purpose
%%of the normalization factor is to achieve the same average power for all mappings.In practical
%%implementations, an approximate value of the normalization factor can be used, as long as
%%the device conforms with the modulation accuracy requirements .
%%-------------------------------------------------------------------------
%% Input:
%%-------------------------------------------------------------------------
%% mod_in:輸入的二進制序列(The sequence to be modulated)
%%-------------------------------------------------------------------------
%% Output:
%%-------------------------------------------------------------------------
%% mod_out:星座圖映射后得到的調制復數結果(The output after modulation)
%%-------------------------------------------------------------------------
%% Global Variable:
%% g_RT (the vector which contains the modulation mode)
%%-------------------------------------------------------------------------
%% Z :選擇調制方式的參數 (the parameter to choose the modulation mode)
%%
%% R :輸入二進制序列重新排列(按一定要求)后的結果,例如:對16QAM,要把輸入序列調整為
%% 4行,length(g_MOD_IN_16QAM )/4 列的矩陣。(Reshape the input binary sequence to be
%% matrix of n-row,m-column .For example,16QAM,will be reshaped into 4-row,
%%length(g_MOD_IN_16QAM))/4 column )
%%
%% B2D :二進制向十進制轉化后的結果 (convert the binary sequence to dec )
%%
%% Temp:星座圖陣列 (the constellation)
%%-------------------------------------------------------------------------
%%********************************************************
%system_parameters
switch (mod_mode)
case 2
for i=1:length(mod_in)
if mod_in(i)==0
mod_out(i)=-1;
else mod_out(i)=1;%完成星座圖的映射 (mapping)
end
end
%disp(mod_out) %輸出結果
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
case 4
mod_out=zeros(1,length(mod_in)/2);
R=reshape(mod_in,2,length(mod_in)/2); %將輸入序列轉化為(2,length(x)/2)的矩陣
B2D=bi2de(R','left-msb')+1; %將二進制轉為十進制,注意加1,因為matlab沒有a(0)項,而是從a(1)開始 left-msb:表明左邊為最高位 --yzh
Temp=[-1-j -1+j 1-j 1+j];
for i=1:length(mod_in)/2
mod_out(i)=Temp(B2D(i))/sqrt(2);%歸一化
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
case 16
mod_out=zeros(1,length(mod_in)/4);
R=reshape(mod_in,4,length(mod_in)/4);
B2D=bi2de(R','left-msb')+1;
Temp=[-3-3*j -3-j -3+3*j -3+j ...
-1-3*j -1-j -1+3*j -1+j ...
3-3*j 3-j 3+3*j 3+j ...
1-3*j 1-j 1+3*j 1+j];
for i=1:length(mod_in)/4
mod_out(i)=Temp(B2D(i))/sqrt(10);
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
case 64
mod_out=zeros(1,length(mod_in)/6);
R=reshape(mod_in,6,length(mod_in)/6);
B2D=bi2de(R','left-msb')+1;
Temp=[-7-7*j -7-5*j -7-j -7-3*j -7+7*j -7+5*j -7+j -7+3*j...
-5-7*j -5-5*j -5-j -5-3*j -5+7*j -5+5*j -5+j -5+3*j...
-1-7*j -1-5*j -1-j -1-3*j -1+7*j -1+5*j -1+j -1+3*j...
-3-7*j -3-5*j -3-j -3-3*j -3+7*j -3+5*j -3+j -3+3*j...
7-7*j 7-5*j 7-j 7-3*j 7+7*j 7+5*j 7+j 7+3*j...
5-7*j 5-5*j 5-j 5-3*j 5+7*j 5+5*j 5+j 5+3*j...
1-7*j 1-5*j 1-j 1-3*j 1+7*j 1+5*j 1+j 1+3*j...
3-7*j 3-5*j 3-j 3-3*j 3+7*j 3+5*j 3+j 3+3*j ];
for i=1:length(mod_in)/6
mod_out(i)=Temp(B2D(i))/sqrt(42);
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
otherwise
disp('Error! Please input again');
end
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -