我在matlab中使用瑞利衰落的M-QAM调制,我对集成部分有一点问题,我用近似值制作了那个代码:
function y = m_qam_ray( M )
%UNTITLED4 Summary of this function goes here
% Detailed explanation goes here
% simulation for M-QAM transmission
EbNodB = [0:2:40];
EbNolin = 10.^(EbNodB/10) ;
Pe_sim=[];
% For M-QAM
if(M==4)
a=1;
else
a=4/log2(M);
end
b=3*log2(M)/(M-1);
Pe=[];
for i = 1:((40/2)+1),
Pe= [Pe 0.5*a*(1-sqrt(0.5*b*EbNolin(i)/(1+0.5*b*EbNolin(i))))]; %THE APROXIMATION
end % Ref: Wireless Communication, A. Goldsmith
semilogy(EbNodB,Pe)
xlabel('SNR, EbNo(dB)');
ylabel('Bit error probability, Pe');
title('Theoretical results of BER of M-QAM');
legend(num2str(M));
legend('-DynamicLegend')
hold off
end
该代码可以正常工作,但现在我需要进行修改,必须修改 aproximation 指示的行,而不是
0.5*a*(1-sqrt(0.5*b*EbNolin(i)/(1+0.5*b*EbNolin(i))))
我需要一个新值:
(a/pi)*int((a/pi)*mgf*(-b/(2*((sin(phi))^2)) integrated from phi = 0..pi/2
在哪里
mgf = (2*(sin(phi))^2)/(2*(sin(phi))^2+b*EbNolin)
所以我将我的代码修改为:
function y= m_qam_ray2(M)
%UNTITLED4 Summary of this function goes here
% Detailed explanation goes here
% simulation for M-QAM transmission
EbNodB = [0:2:40];
EbNolin = 10.^(EbNodB/10) ;
%Pe_sim=[];
if(M==4)
a=1; %Amplitud alpha_m
else
a=(4/log2(M))*(1-(1/sqr(M)));
end
b=3*log2(M)/(M-1); %beta_m
%mgf= (2*(sin(phi))^2)/(2*(sin(phi))^2+b*EbNolin);
Pe=[];
for i = 1:((40/2)+1),
Pe= [Pe (a/pi)*int((a/pi)*((2*((sin(phi))^2)/(2*((sin(phi))^2)+b*EbNolin(i)))*(-b/(2*((sin(phi))^2)), phi = 0..pi/2)];
end % Ref: Wireless Communication, A. Goldsmith
semilogy(EbNodB,Pe)
xlabel('SNR, EbNo(dB)');
ylabel('Bit error probability, Pe');
title('Theoretical results of BER of M-QAM');
legend(num2str(M));
legend('-DynamicLegend')
hold off
结尾
在 i 的每个循环中,我都在做 0 和 pi/2 之间的积分(我知道它不是很有效,但现在我只需要它工作),但我不断收到错误并且不知道确切原因,错误行是这
Pe = [Pe (a/pi)*int(((2*((sin(phi))^2)/(2*((sin(phi))^2)+b*EbNolin(i)))*(-b/(2*((sin(phi))^2)))), phi = 0..pi/2)];
错误是???错误:文件:m_qam_ray2.m 行:22 列:108 等号左侧的表达式不是赋值的有效目标。
而且我不知道是因为我的循环编程错误还是因为积分。
如果有人可以提供帮助,我将不胜感激。
谢谢 :)