?? modulation.m
字號(hào):
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:
%%-------------------------------------------------------------------------
%%根據(jù)輸入的調(diào)制方式,對(duì)輸入序列MOD_IN進(jìn)行調(diào)制,分別采用BPSK, QPSK, !6QAM, 64QAM,
%%完成對(duì)星座圖的映射,輸出為Y.轉(zhuǎn)化的方法為:先寫出十進(jìn)制情況下從0 到N-1
%%(N為星座圖的點(diǎn)數(shù))所對(duì)應(yīng)的星座坐標(biāo);再將輸入的二進(jìn)制序列轉(zhuǎn)化為相應(yīng)的
%%十進(jìn)制,以查表的方法查出對(duì)應(yīng)點(diǎn)的復(fù)數(shù)坐標(biāo),即為調(diào)制映射后的結(jié)果。
%%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:輸入的二進(jìn)制序列(The sequence to be modulated)
%%-------------------------------------------------------------------------
%% Output:
%%-------------------------------------------------------------------------
%% mod_out:星座圖映射后得到的調(diào)制復(fù)數(shù)結(jié)果(The output after modulation)
%%-------------------------------------------------------------------------
%% Global Variable:
%% g_RT (the vector which contains the modulation mode)
%%-------------------------------------------------------------------------
%% Z :選擇調(diào)制方式的參數(shù) (the parameter to choose the modulation mode)
%%
%% R :輸入二進(jìn)制序列重新排列(按一定要求)后的結(jié)果,例如:對(duì)16QAM,要把輸入序列調(diào)整為
%% 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 :二進(jìn)制向十進(jìn)制轉(zhuǎn)化后的結(jié)果 (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) %輸出結(jié)果
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
case 4
mod_out=zeros(1,length(mod_in)/2);
R=reshape(mod_in,2,length(mod_in)/2); %將輸入序列轉(zhuǎn)化為(2,length(x)/2)的矩陣
B2D=bi2de(R','left-msb')+1; %將二進(jìn)制轉(zhuǎn)為十進(jìn)制,注意加1,因?yàn)閙atlab沒有a(0)項(xiàng),而是從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
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -