Matlab自定义函数画仿真结果

Self-Definition Function For Plotting Simulation Results



一、Parameters Setting

POINT_NUMBER = 10;  
LINE_INTERVAL = 50;
FONT_SIZE = 8.0;
FIGURE_SIZE = [7 7 7 7]; 
COORDINATE_LIMITATION = [0, 1000, 0, 500] ;  % [x_Starting, x_ending, y_Starting, y_ending]
FIGURE_RATIO = [0.065 0.10 0.85 0.85];
LINE_WIDTH = 1.5;
MARKER_SIZE = 5;

二、Self-definition Function

代码如下(示例):

function [  ] = plotSimulationResults(  DataArray1,DataArray2,... %DataArray3,DataArray4,
                                        POINT_NUMBER, LINE_INTERVAL,...
                                        FONT_SIZE, FIGURE_SIZE, COORDINATE_LIMITATION, FIGURE_RATIO, LINE_WIDTH, MARKER_SIZE  )

figure('Name','The compartion of xxx','color',[1 1 1]);
set(gca,'fontsize',FONT_SIZE);                 %set the font size
set(gcf,'Units','centimeter','Position',FIGURE_SIZE); % FIGURE_SIZE = [8, 8, 8, 8] 
axis(COORDINATE_LIMITATION); %[x_begining, x_ending, y_begining, y_ending]
set(gca,'Position',FIGURE_RATIO);       % for removing white margin 
grid;
xlabel('x (times)');
ylabel('y (%)');
hold on;

RoundNumber = length(DataArray1);

DataArray1 = [0,DataArray1];
DataArray2 = [0,DataArray2];
% DataArray3 = [0,DataArray3];
% DataArray4 = [0,DataArray4];

pointInterval = RoundNumber./POINT_NUMBER;
pointBeginPoint = 0;
lineBeginPoint = 0;

for index =  pointBeginPoint:pointInterval:RoundNumber 
    plot( index, DataArray1( index+1 ),'Color','blue','Marker','x','MarkerFaceColor','blue','MarkerSize',MARKER_SIZE);
    plot( index, DataArray2( index+1 ),'Color','red','Marker','<','MarkerFaceColor','red','MarkerSize',MARKER_SIZE);
%     plot( index, DataArray3( index+1 ),'Color','green','Marker','d','MarkerFaceColor','green','MarkerSize',MARKER_SIZE);
%     plot( index, DataArray4( index+1 ),'Color','black','Marker','o','MarkerFaceColor','black','MarkerSize',MARKER_SIZE);
    hold on;
end

plot( lineBeginPoint:LINE_INTERVAL:RoundNumber,DataArray1(1:LINE_INTERVAL:(RoundNumber+1)),'Color','blue ','LineStyle','-','LineWidth',LINE_WIDTH); % The LineStyle parameter where you can set to '-', '--', ':', or ':.'  
hold on;
plot( lineBeginPoint:LINE_INTERVAL:RoundNumber,CentralizedCoverageRadioArray(1:LINE_INTERVAL:(RoundNumber+1)),'Color','red ','LineStyle','-','LineWidth',LINE_WIDTH);
hold on;
% plot( lineBeginPoint:lineInterval:RoundNumber,DataArray3(1:lineInterval:(RoundNumber+1)),'Color','green ','LineStyle','-','LineWidth',LINE_WIDTH);
% hold on;
% plot( lineBeginPoint:lineInterval:RoundNumber,DataArray4(1:lineInterval:(RoundNumber+1)),'Color','black ','LineStyle','-','LineWidth',LINE_WIDTH);
% hold on;

legend_ = legend('Algorithm1','Algorithm2','Algorithm3','Algorithm4');  % set the name for the legend
set(legend_,'Location','NorthWest');   % set the location of the legend,and the paramecter where you can set to NorthWest, NorthEast, SouthWest, or SouthEast.

end

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值