matlab的一小段代码,为什么不出来正确图形?求大神额R=1;for N_max=1:1:3L3=[];for SNR=0:1:20; SNR_ad=SNR; SNR_bd=SNR; SNR_rd=SNR; m=exp(-(2^R-1)/(10^(SNR_ad/10))); n=exp(-(2^R-1)/(10^(SNR_bd/10)))
来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/19 19:26:50
matlab的一小段代码,为什么不出来正确图形?求大神额R=1;for N_max=1:1:3L3=[];for SNR=0:1:20; SNR_ad=SNR; SNR_bd=SNR; SNR_rd=SNR; m=exp(-(2^R-1)/(10^(SNR_ad/10))); n=exp(-(2^R-1)/(10^(SNR_bd/10)))
matlab的一小段代码,为什么不出来正确图形?求大神额
R=1;
for N_max=1:1:3
L3=[];
for SNR=0:1:20;
SNR_ad=SNR;
SNR_bd=SNR;
SNR_rd=SNR;
m=exp(-(2^R-1)/(10^(SNR_ad/10)));
n=exp(-(2^R-1)/(10^(SNR_bd/10)));
p=exp(-(2^R-1)/(10^(SNR_rd/10)));
U=(1-m)*(1-p)*p;
V=(1-n)*(1-p)*p;
P_A=(1-(1-m)*(1-p));
P_B=(1-(1-n)*(1-p));
for K=1:1:N_max
P_A=P_A+U*(1-p)^(K-1);
P_B=P_B+V*(1-p)^(K-1);
end
P_out2=1-P_A*P_B;
L3=[L3 P_out2];%Nmax次重传的中断概率
end
switch N_max
case 1
plot(0:1:20,L3,'--xr');
case 2
plot(0:1:20,L3,'--*r');
case 3
plot(0:1:20,L3,'--vr');
end%此循环程序实现不同Nmax值对应的中断概率仿真图
end
matlab的一小段代码,为什么不出来正确图形?求大神额R=1;for N_max=1:1:3L3=[];for SNR=0:1:20; SNR_ad=SNR; SNR_bd=SNR; SNR_rd=SNR; m=exp(-(2^R-1)/(10^(SNR_ad/10))); n=exp(-(2^R-1)/(10^(SNR_bd/10)))
clear,clc,clf
hold on;
R=1;
for N_max=1:1:3
L3=[];
for SNR=0:1:20;
SNR_ad=SNR;
SNR_bd=SNR;
SNR_rd=SNR;
m=exp(-(2^R-1)/(10^(SNR_ad/10)));
n=exp(-(2^R-1)/(10^(SNR_bd/10)));
p=exp(-(2^R-1)/(10^(SNR_rd/10)));
U=(1-m)*(1-p)*p;
V=(1-n)*(1-p)*p;
P_A=(1-(1-m)*(1-p));
P_B=(1-(1-n)*(1-p));
for K=1:1:N_max
P_A=P_A+U*(1-p)^(K-1);
P_B=P_B+V*(1-p)^(K-1);
end
P_out2=1-P_A*P_B;
L3=[L3 P_out2];%Nmax次重传的中断概率
end
switch N_max
case 1
plot(0:1:20,L3,'--xr');
case 2
plot(0:1:20,L3,'--*g');
case 3
plot(0:1:20,L3,'--vb');
end%此循环程序实现不同Nmax值对应的中断概率仿真图
end
hold off;