www.pudn.com > kalman.zip > safestate.m, change:2014-11-06,size:1189b


B=[];
A=importdata('row3.csv');     %导入数据
A=A+10;
i=1;
while i<=length(A)            
    if A(i)>=40       
        A(i)=[];
    else
        i=i+1;
    end
end
x=1:5548;
B=A-5;                         
figure
[AX,H1,H2]=plotyy(x,A,x,B);    %两副图画在一起

%获得左边坐标的句柄,进行设置,
HH1=get(AX(1),'Ylabel');     
set(HH1,'String','攻击强度','fontsize',16,'color','b'); 
set(AX(1),'XColor','k','YColor','b','ylim',[0,60],'YTick',[10,20,30,40,50,60],'yticklabel',[5000,10000,15000,20000,25000,30000],'ygrid','on','xlim',[0,5400],'xtick',[0,900,1800,2700,3600,4500,5400],'xticklabel',[0,20,40,60,80,100,120]);

%获得右边坐标的句柄,进行设置,
HH2=get(AX(2),'Ylabel')  
set(HH2,'String','安全态势','fontsize',16,'color','k'); 
set(AX(2),'XColor','k','YColor','k','ylim',[0,60],'YTick',[10,20,30,40,50,60],'xlim',[0,5400],'xtick',[0,900,1800,2700,3600,4500,5400],'yticklabel',[0,0.2,0.4,0.6,0.8,1],'xticklabel',[0,20,40,60,80,100,120]);

%设置曲线的属性
set(H1,'LineStyle','-','linewidth',3); 
set(H1,'color','b'); 
set(H2,'LineStyle','-'); 
set(H2,'color','k');  

%设置x轴的属性
xlabel('时刻/秒','fontsize',16);


%设置图例属性
h=legend('攻击强度','风险',2);
set(h,'FontSize',20)