《量化投资:以MATLAB为工具》

MATLAB技术论坛

 找回密码
 注册账号
查看: 45|回复: 0
收起左侧

[提问] 求大神指导,拜谢

[复制链接]

该用户从未签到

发表于 2017-12-6 09:54:59 | 显示全部楼层 |阅读模式

如图,我需要把三个图画在一起,用双坐标轴显示,但是右侧纵坐标轴刻度重复了,研究半天,调不出来,求大神指导哈。
代码如下:
clc
clear
syms a;
VA=5;
V=VA+1;
epsilon=0.05;
alpha=0.2;
beta=0.95;
RR=[];
BB=[];
LL=[];
for L=0:1:100
    T=10^(-alpha*L/10);
    kai=epsilon+(1-T)/T;
    b=a*sqrt(T/(2*(kai+1)));
    F=V^2*(1-2*T)+2*T+T^2*(V+kai)^2;
    D=T*(V*kai+1);
    x=(T*(V+kai)+1)/(T*(kai+1)+1);
    y1=sqrt(0.5*(F+sqrt(F^2-4*D^2)));
    y2=sqrt(0.5*(F-sqrt(F^2-4*D^2)));
    [IAB,Sb]=het_b(x,y1,y2);
    lambda=(T*(V*kai+1)+V)/(T*(V+kai)+1);
    Sa=entropy_a(lambda);
    R=beta*IAB-Sb+Sa;
    f=MATLABFunction((1./(sqrt(2*pi*VA)))*exp(-a.^2./(2*VA))*0.5*erfc(b));
    B=2*integral(f,0,6);
    BB=[BB B];
    RR=[RR R];
    LL=[LL L];
end
[AX,H1,H2]=plotyy(LL,RR,LL,BB,@semilogy,@plot);
set(H1,'Linestyle','-','color','r');
set(H2,'Linestyle','-','color','r');  
hold on;

clc
clear
syms a;
VA=14;
V=VA+1;
epsilon=0.05;
alpha=0.2;
beta=0.95;
RR=[];
BB=[];
LL=[];
for L=0:1:100
    T=10^(-alpha*L/10);
    kai=epsilon+(1-T)/T;
    F=V^2*(1-2*T)+2*T+T^2*(V+kai)^2;
    D=T*(V*kai+1);
    x=(T*(V+kai)+1)/(T*(kai+1)+1);
    y1=sqrt(0.5*(F+sqrt(F^2-4*D^2)));
    y2=sqrt(0.5*(F-sqrt(F^2-4*D^2)));
    [IAB,Sb]=het_b(x,y1,y2);
    lambda=(T*(V*kai+1)+V)/(T*(V+kai)+1);
    Sa=entropy_a(lambda);
    R=beta*IAB-Sb+Sa;
    b=a*sqrt(T/(2*(kai+1)));
    f=matlabFunction((1./(sqrt(2*pi*VA)))*exp(-a.^2./(2*VA))*0.5*erfc(b));
    B=2*integral(f,0,6);
    BB=[BB B];
    RR=[RR R];
    LL=[LL L];
end
[AX,H1,H2]=plotyy(LL,RR,LL,BB,@semilogy,@plot);
set(H1,'Linestyle','--','color','g');
set(H2,'Linestyle','--','color','g');  
hold on;

clc
clear
syms a;
VA=40;
V=VA+1;
epsilon=0.05;
alpha=0.2;
beta=0.95;
RR=[];
BB=[];
LL=[];
for L=0:1:100
    T=10^(-alpha*L/10);
    kai=epsilon+(1-T)/T;
    F=V^2*(1-2*T)+2*T+T^2*(V+kai)^2;
    D=T*(V*kai+1);
    x=(T*(V+kai)+1)/(T*(kai+1)+1);
    y1=sqrt(0.5*(F+sqrt(F^2-4*D^2)));
    y2=sqrt(0.5*(F-sqrt(F^2-4*D^2)));
    [IAB,Sb]=het_b(x,y1,y2);
    lambda=(T*(V*kai+1)+V)/(T*(V+kai)+1);
    Sa=entropy_a(lambda);
    R=beta*IAB-Sb+Sa;
    b=a*sqrt(T/(2*(kai+1)));
    f=matlabFunction((1./(sqrt(2*pi*VA)))*exp(-a.^2./(2*VA))*0.5*erfc(b));
    B=2*integral(f,0,6);
    BB=[BB B];
    RR=[RR R];
    LL=[LL L];
end
[AX,H1,H2]=plotyy(LL,RR,LL,BB,@semilogy,@plot);
set(get(AX(1),'ylabel'),'string', '安全码率(bit/pulse)');
set(get(AX(2),'ylabel'),'string', '误码率');
xlabel('传输距离(km)');
set(H1,'Linestyle','-.','color','k');
set(H2,'Linestyle','-.','color','k');  
set(AX(:),'Ycolor','k');
legend('VA=5','VA=14','VA=40');

右侧坐标刻度重复

右侧坐标刻度重复
您需要登录后才可以回帖 登录 | 注册账号

本版积分规则

QQ|网站地图|MATLAB技术论坛|Simulink仿真论坛 ( 陕ICP备08102094号  

GMT+8, 2017-12-16 05:36 , Processed in 0.092647 second(s), 30 queries , Gzip On.

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表