概述
modulation.m
function output_modu = modulation(input_frame, index)
% Input_modu: input bit stream (0,1)
% index: modulation index
% 1---bpsk
% 2---qpsk
% 4---16qam
% 6---64qam
% else is error
f_length = length(input_frame)/index;
QAM_input_I = zeros(1,f_length);
QAM_input_Q = zeros(1,f_length);
% note: Matlab index starts from 1
switch index
case 1,
BPSK_I = [-1 1]; % refer to Table82 on page21 of IEEE802.11a
QAM_input_I = BPSK_I(input_frame+1);
output_modu = QAM_input_I ;
case 2,
QPSK_IQ = [-1 1]; % refer to Table83 on page21 of IEEE802.11a
QAM_input_I = QPSK_IQ(input_frame(1:2:end)+1);
QAM_input_Q = QPSK_IQ(input_frame(2:2:end)+1);
output_modu = QAM_input_I + j * QAM_input_Q;
case 3,
mapping=[3+i 1+i -3+i -1+i -3-i -1-i 3-i 1-i ];
output_modu=mapping(input_frame(1:3:end)*4+input_frame(2:3:end)*2+input_frame(3:3:end)+1);
case 4,
QAM_16_IQ = [-3 -1 3 1]; % refer to Table84 on page21 of IEEE802.11a
QAM_input_I = QAM_16_IQ(input_frame(1:4:end)*2+input_frame(2:4:end)+1);
QAM_input_Q = QAM_16_IQ(input_frame(3:4:end)*2+input_frame(4:4:end)+1);
output_modu = QAM_input_I + j * QAM_input_Q;
case 5,
mapping=[5+i 3+i 1+i 5+3*i 3+3*i 1+3*i 3+5*i 1+5*i -5+i -3+i -1+i -5+3*i -3+3*i -1+3*i -3+5*i -1+5*i -5-i -3-i -1-i -5-3*i -3-3*i -1-3*i -3-5*i -1-5*i 5-i 3-i 1-i 5-3*i 3-3*i 1-3*i 3-5*i 1-5*i];
output_modu=mapping(input_frame(1:5:end)*16+input_frame(2:5:end)*8+input_frame(3:5:end)*4+input_frame(4:5:end)*2+input_frame(5:5:end)+1);
case 6,
QAM_64_IQ = [-7 -5 -1 -3 7 5 1 3]; % refer to Table85 on page21 of IEEE802.11a
QAM_input_I = QAM_64_IQ(input_frame(1:6:end)*4+input_frame(2:6:end)*2+input_frame(3:6:end)+1);
QAM_input_Q = QAM_64_IQ(input_frame(4:6:end)*4+input_frame(5:6:end)*2+input_frame(6:6:end)+1);
output_modu = QAM_input_I + j * QAM_input_Q;
end
demodulation.m
function output_frame = demodulation(input_modu, index)
% demodulation for IEEE802.11a
% Input: input_modu, complex values representing constellation points
% index
% Output: output_frame, output bit stream (data unit is one bit)
% In this version, increase the quatilization levels into 8.
% note: Matlab index starts from 1
Q_length=length(input_modu);
QAM_input_I = real(input_modu);
QAM_input_Q = imag(input_modu);
output_frame = zeros(1,length(input_modu)*index);
switch index
case 1,
BPSK_Demodu_I = [0 1]; %f(m)=(m+1)/2 + 1, so I=-1 ---> 1, I=1 ---> 2
idx = find(QAM_input_I>1);
QAM_input_I(idx) = 1;
idx = find(QAM_input_IQAM_input_I(idx) = -1;
output_frame = BPSK_Demodu_I(round((QAM_input_I+1)/2) + 1);
case 2,
QPSK_Demodu_IQ = [0 1]; %f(m)=(m+1)/2 + 1, so I=-1 ---> 1, I=1 ---> 2
idx = find(QAM_input_I>1);
QAM_input_I(idx) = 1;
idx = find(QAM_input_IQAM_input_I(idx) = -1;
idx = find(QAM_input_Q>1);
QAM_input_Q(idx) = 1;
idx = find(QAM_input_
最后
以上就是成就蚂蚁为你收集整理的bpsk调制matlab,用MATLAB实现的BPSK调制解调源程序的全部内容,希望文章能够帮你解决bpsk调制matlab,用MATLAB实现的BPSK调制解调源程序所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复