石狮网站建设价格,云南省建设工程招标投标行业协会网站,南宁软件优化网站,中山h5网站建设学习的背景说明
因为在学习5G物理层#xff0c;一直很忙#xff0c;没有时间。最近稍有一点空闲#xff0c;所以#xff0c;学习一下算法。 QPSK的算法#xff0c;虽然说我没有完全学透#xff0c;大致还是懂的。只能一直没时间用MATLAB来研究一下。
然后看到这个实例一直很忙没有时间。最近稍有一点空闲所以学习一下算法。 QPSK的算法虽然说我没有完全学透大致还是懂的。只能一直没时间用MATLAB来研究一下。
然后看到这个实例感觉很好。因为没有中间的AWGN和采样的过程只讲调制与解调适合理解。 示例代码见下
QPSK_MOD_DEMOD_SALIM MATLAB Code for QPSK Modulation and Demodulation - File Exchange - MATLAB Central MATLAB Code for QPSK Modulation and Demodulation
Version 1.0.0.0 (2.99 KB) by Md. Salim Raza
MATLAB Code for QPSK Modulation and Demodulation has been Developed According to Conventional Theory
%XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX%XXXX QPSK Modulation and Demodulation without consideration of noise XXXXX%XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXclc;
clear all;
close all;
data[0 1 0 1 1 1 0 0 1 1]; % information
%Number_of_bit1024;
%datarandint(Number_of_bit,1);
figure(1)
stem(data, linewidth,3), grid on;
title( Information before Transmiting );
axis([ 0 11 0 1.5]);
data_NZR2*data-1; % Data Represented at NZR form for QPSK modulation
s_p_datareshape(data_NZR,2,length(data)/2); % S/P convertion of data
br10.^6; %Let us transmission bit rate 1000000
fbr; % minimum carrier frequency
T1/br; % bit duration
tT/99:T/99:T; % Time vector for one bit information
% XXXXXXXXXXXXXXXXXXXXXXX QPSK modulatio XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
y[];
y_in[];
y_qd[];
for(i1:length(data)/2)
y1s_p_data(1,i)*cos(2*pi*f*t); % inphase component
y2s_p_data(2,i)*sin(2*pi*f*t) ;% Quadrature component
y_in[y_in y1]; % inphase signal vector
y_qd[y_qd y2]; %quadrature signal vector
y[y y1y2]; % modulated signal vector
end
Tx_sigy; % transmitting signal after modulation
ttT/99:T/99:(T*length(data))/2;
figure(2)
subplot(3,1,1);
plot(tt,y_in,linewidth,3), grid on;
title( wave form for inphase component in QPSK modulation );
xlabel(time(sec));
ylabel( amplitude(volt0);
subplot(3,1,2);
plot(tt,y_qd,linewidth,3), grid on;
title( wave form for Quadrature component in QPSK modulation );
xlabel(time(sec));
ylabel( amplitude(volt0);
subplot(3,1,3);
plot(tt,Tx_sig,r,linewidth,3), grid on;
title(QPSK modulated signal (sum of inphase and Quadrature phase signal));
xlabel(time(sec));
ylabel( amplitude(volt0);
% XXXXXXXXXXXXXXXXXXXXXXXXXXXX QPSK demodulation XXXXXXXXXXXXXXXXXXXXXXXXXX
Rx_data[];
Rx_sigTx_sig; % Received signal
for(i1:1:length(data)/2)
%%XXXXXX inphase coherent dector XXXXXXX
Z_inRx_sig((i-1)*length(t)1:i*length(t)).*cos(2*pi*f*t);
% above line indicat multiplication of received inphase carred signal
Z_in_intg(trapz(t,Z_in))*(2/T);% integration using trapizodial rull
if(Z_in_intg0) % Decession Maker
Rx_in_data1;
else
Rx_in_data0;
end
%%XXXXXX Quadrature coherent dector XXXXXX
Z_qdRx_sig((i-1)*length(t)1:i*length(t)).*sin(2*pi*f*t);
%above line indicat multiplication ofreceived Quadphase carred signal
Z_qd_intg(trapz(t,Z_qd))*(2/T);%integration using trapizodial rull
if (Z_qd_intg0)% Decession Maker
Rx_qd_data1;
else
Rx_qd_data0;
end
Rx_data[Rx_data Rx_in_data Rx_qd_data]; % Received Data vector
end
figure(3)
stem(Rx_data,linewidth,3)
title(Information after Receiveing );
axis([ 0 11 0 1.5]), grid on;
% XXXXXXXXXXXXXXXXXXXXXXXXX end of program XXXXXXXXXXXXXXXXXXXXXXXXXX运行的结果如图 单步跟踪代码后基本都能理解。 特别是调制的部分都比较熟悉 S(t)I⋅cos(2πft)Q⋅sin(2πft) 这里稍加注意中国的教科书大多I与Q是正负相反的也就是在空间的旋转方向相反但国外包括wiki百科都是相加的也就是同向。 matlab显然是同向的所以是相加。 但是到解调时就有些看不懂了。
这一句 Z_in_intg(mytrapz(t,Z_in))(2/T);% integration using trapizodial rull 为什么积分是0或者0而不是等于0? 这里我研究了好半天。 最后发现是这样的 调制时这一句 y1 s_p_data(1,i)cos(2pift); % inphase component 将一个信号例如这里是1乘以cos(2pift)。 可以简单理解为将直流信号装到一个cos的载波上。 解调时先 Z_inRx_sig((i-1)length(t)1:ilength(t)).cos(2pift); 待解的符号再次乘以cos(2pif*t); 这样就得到了cos的平方。 从而积分值0 或者 0而不是等于零。
同样,Q路信号,调制和解调,分别被乘以一次sin ,所以是sin的平方。所以积分不再是零。
如下图将第一个IQ数据改为 data[-5 1]; % information 第一次将图形输出出来之后没有看懂的原因如上图没有看Y轴坐标还以为是从-1到正1其坐标已经变了。都在X轴之上或之下。积分自然不再是零。
附改之后用于学习的调试代码
%XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
%XXXX QPSK Modulation and Demodulation without consideration of noise XXXXX
%XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXclc;
clear all;
close all;
% data[0 0 1 0 1 1 0 1]; % information
% data[0 1 1 0 1 1 0 0]; % information
data[-1 1]; % information
%Number_of_bit1024;
%datarandint(Number_of_bit,1);figure(1)
stem(data, linewidth,3), grid on;
title( Information before Transmiting );
axis([ 0 11 0 1.5]);data_NZR2*data-1; % Data Represented at NZR form for QPSK modulation
s_p_datareshape(data_NZR,2,length(data)/2); % S/P convertion of databr10.^6; %Let us transmission bit rate 1000000
fbr; % minimum carrier frequency
T1/br; % bit duration
tT/99:T/99:T; % Time vector for one bit information% XXXXXXXXXXXXXXXXXXXXXXX QPSK modulatio XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
y[];
y_in[];
y_qd[];
for(i1:length(data)/2) y1 s_p_data(1,i)*cos(2*pi*f*t); % inphase componenty2s_p_data(2,i)*sin(2*pi*f*t) ;% Quadrature componenty_in[y_in y1]; % inphase signal vectory_qd[y_qd y2]; %quadrature signal vectory[y y1y2]; % modulated signal vector
end
Tx_sigy1; % transmitting signal after modulation
ttT/99:T/99:(T*length(data))/2;figure(2)subplot(3,1,1);
plot(tt,y_in,linewidth,3), grid on;
title( wave form for inphase component in QPSK modulation );
xlabel(time(sec));
ylabel( amplitude(volt0);subplot(3,1,2);
plot(tt,y_qd,linewidth,3), grid on;
title( wave form for Quadrature component in QPSK modulation );
xlabel(time(sec));
ylabel( amplitude(volt0);subplot(3,1,3);
plot(tt,Tx_sig,r,linewidth,3), grid on;
title(QPSK modulated signal (sum of inphase and Quadrature phase signal));
xlabel(time(sec));
ylabel( amplitude(volt0);% XXXXXXXXXXXXXXXXXXXXXXXXXXXX QPSK demodulation XXXXXXXXXXXXXXXXXXXXXXXXXX
figure(3)
Rx_data[];
Rx_sigTx_sig; % Received signal
for(i1:1:length(data)/2)Z_Rx_ori_symRx_sig((i-1)*length(t)1:i*length(t));subplot(2,1,1);plot(t,Z_Rx_ori_sym,linewidth,3), grid on;title(I: Z_Rx_ori_sym );xlabel(time(sec));ylabel( amplitude(volt0);%%XXXXXX inphase coherent dector XXXXXXXZ_inRx_sig((i-1)*length(t)1:i*length(t)).*cos(2*pi*f*t); %Z_inRx_sig((i-1)*length(t)1:i*length(t)); % above line indicat multiplication of received inphase carred signalsubplot(2,1,2);plot(t,Z_in,linewidth,3), grid on;title(I: Z_in);xlabel(time(sec));ylabel( amplitude(volt0);Z_in_intg(mytrapz(t,Z_in))*(2/T);% integration using trapizodial rullif(Z_in_intg0) % Decession MakerRx_in_data1;elseRx_in_data0; end%%XXXXXX Quadrature coherent dector XXXXXXZ_qdRx_sig((i-1)*length(t)1:i*length(t)).*sin(2*pi*f*t);%above line indicat multiplication ofreceived Quadphase carred signalZ_qd_intg(trapz(t,Z_qd))*(2/T);%integration using trapizodial rullif (Z_qd_intg0)% Decession MakerRx_qd_data1;elseRx_qd_data0; endRx_data[Rx_data Rx_in_data Rx_qd_data]; % Received Data vector
endfigure(4)
stem(Rx_data,linewidth,3)
title(Information after Receiveing );
axis([ 0 11 0 1.5]), grid on;% XXXXXXXXXXXXXXXXXXXXXXXXX end of program XXXXXXXXXXXXXXXXXXXXXXXXXX