• matlab绘图代码(将几个数据绘制到一个figure中)


    1. % %step1
    2. % load('GaPid.mat');
    3. % load('FuzzyPid.mat');
    4. % load('Pid.mat');
    5. % load('step1.mat');
    6. % load('test.mat');
    7. % plot(step1.time,step1.signals.values,'r','LineWidth',1);
    8. % hold on;
    9. % plot(test.time,test.signals.values,'.-k','LineWidth',1);
    10. % hold on;
    11. % plot(FuzzyPid.time,FuzzyPid.signals.values,'b','LineWidth',1);
    12. % hold on;
    13. % plot(GaPid.time,GaPid.signals.values,'g','LineWidth',1);
    14. % hold on;
    15. % plot(Pid.time,Pid.signals.values,'m','LineWidth',1);
    16. % set(gca,'FontSize',30);%设置坐标轴
    17. %
    18. % xlabel('Time/s','FontSize',30,'FontName','Times Rew Roman');
    19. % ylabel('F/N','FontSize',30,'FontName','Times Rew Roman');
    20. % %增加图例
    21. % legend('STEP','Ga Fuzzy PID','Fuzzy PID','Ga PID','PID','FontSize',20,'FontName','Times Rew Roman','Location','NorthEast');
    22. %legend('boxoff') %取消图例边框
    23. % %设置背景为白色
    24. % set(gcf,'color','w');
    25. % box off;
    26. %
    27. %
    28. % axes('Position',[0.5,0.2,0.25,0.35]);
    29. % plot(step1.time,step1.signals.values,'r','LineWidth',1);
    30. % hold on;
    31. % plot(test.time,test.signals.values,'.-k','LineWidth',1);
    32. % hold on;
    33. % plot(FuzzyPid.time,FuzzyPid.signals.values,'b','LineWidth',1);
    34. % hold on;
    35. % plot(GaPid.time,GaPid.signals.values,'g','LineWidth',1);
    36. % hold on;
    37. % plot(Pid.time,Pid.signals.values,'m','LineWidth',1);
    38. % set(gca,'FontSize',20);%设置坐标轴
    39. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    40. %step2
    41. load('GaPidstep2.mat');
    42. load('FuzzyPidstep2.mat');
    43. load('Pidstep2.mat');
    44. load('step2.mat');
    45. load('teststep2.mat');
    46. set(gcf, 'Position', [200 100 1000 600]);
    47. plot(step2.time,step2.signals.values,'r','LineWidth',1);
    48. hold on;
    49. plot(teststep2.time,teststep2.signals.values,'.-k','LineWidth',1);
    50. hold on;
    51. plot(FuzzyPidstep2.time,FuzzyPidstep2.signals.values,'b','LineWidth',1);
    52. hold on;
    53. plot(GaPidstep2.time,GaPidstep2.signals.values,'g','LineWidth',1);
    54. hold on;
    55. plot(Pidstep2.time,Pidstep2.signals.values,'m','LineWidth',1);
    56. set(gca,'FontSize',25);%设置坐标轴
    57. set(gca,'linewidth',1);%坐标轴加粗
    58. xlabel('Time/s','FontSize',25,'FontName','Times Rew Roman');
    59. ylabel('F/N','FontSize',25,'FontName','Times Rew Roman');
    60. %增加图例
    61. legend('Expected Force','Ga Fuzzy PID','Fuzzy PID','Ga PID','PID','FontSize',15,'FontName','Times Rew Roman','Location','NorthWest');
    62. legend('boxoff') %取消图例边框
    63. box off;
    64. ax1 = axes('Position',get(gca,'Position'),'XAxisLocation','top','YAxisLocation','right','Color','none','XColor','k','YColor','k'); % 设置坐标区
    65. set(ax1,'XTick', [],'YTick', []); % 去掉xy轴刻度
    66. set(ax1, 'LineWidth', 1);%加粗线条
    67. %设置背景为白色
    68. set(gcf,'color','w');
    69. box off;
    70. axes('Position',[0.7,0.6,0.20,0.31]);
    71. plot(step2.time,step2.signals.values,'r','LineWidth',1.75);
    72. hold on;
    73. plot(teststep2.time,teststep2.signals.values,'.-k','LineWidth',1);
    74. hold on;
    75. plot(FuzzyPidstep2.time,FuzzyPidstep2.signals.values,'b','LineWidth',1);
    76. hold on;
    77. plot(GaPidstep2.time,GaPidstep2.signals.values,'g','LineWidth',1);
    78. hold on;
    79. plot(Pidstep2.time,Pidstep2.signals.values,'m','LineWidth',1);
    80. set(gca,'FontSize',15);%设置坐标轴
    81. set(gca,'linewidth',1);%坐标轴加粗
    82. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    83. %%正弦曲线
    84. % load('sin.mat');
    85. % load('pidsin.mat');
    86. % load('gasin.mat');
    87. % load('fuzzysin.mat');
    88. % load('testsin.mat');
    89. % % load('step2.mat');
    90. % % load('teststep2.mat');
    91. % set(gcf, 'Position', [200 100 1000 600]);
    92. % plot(sin.time,sin.signals.values,'r','LineWidth',1.75);
    93. % hold on;
    94. % plot(testsin.time,testsin.signals.values,'x-k','LineWidth',1);
    95. % hold on;
    96. % plot(fuzzysin.time,fuzzysin.signals.values,'.--b','LineWidth',1);
    97. % hold on;
    98. % plot(gasin.time,gasin.signals.values,'g','LineWidth',1);
    99. % hold on;
    100. % plot(pidsin.time,pidsin.signals.values,'m','LineWidth',1);
    101. %
    102. % set(gca,'FontSize',25);%设置坐标轴
    103. % set(gca,'linewidth',1);%坐标轴加粗
    104. % xlabel('Time/s','FontSize',25,'FontName','Times Rew Roman');
    105. % ylabel('F/N','FontSize',25,'FontName','Times Rew Roman');
    106. % legend('Expected Force','Ga Fuzzy PID','Fuzzy PID','Ga PID','PID','FontSize',15,'FontName','Times Rew Roman','Location','NorthEast');
    107. % legend('boxoff') %取消图例边框
    108. % box off;
    109. % ax1 = axes('Position',get(gca,'Position'),'XAxisLocation','top','YAxisLocation','right','Color','none','XColor','k','YColor','k'); % 设置坐标区
    110. % set(ax1,'XTick', [],'YTick', []); % 去掉xy轴刻度
    111. % set(ax1, 'LineWidth', 1);%加粗线条
    112. % set(gcf,'color','w');
    113. %
    114. % axes('Position',[0.25,0.72,0.2,0.2]);
    115. % plot(sin.time,sin.signals.values,'r','LineWidth',1.75);
    116. % hold on;
    117. % plot(testsin.time,testsin.signals.values,'.-k','LineWidth',1);
    118. % hold on;
    119. % plot(fuzzysin.time,fuzzysin.signals.values,'.-b','LineWidth',1);
    120. % hold on;
    121. % plot(gasin.time,gasin.signals.values,'g','LineWidth',1);
    122. % hold on;
    123. % plot(pidsin.time,pidsin.signals.values,'m','LineWidth',1);
    124. % set(gca,'FontSize',10);%设置坐标轴
    125. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    126. % %柱状图Y=[426.3075,0.2047,51.5646];
    127. % Y=[426.3075,5,51.5646];
    128. % X=1:3;
    129. % set(gcf, 'Position', [200 100 1000 600]);
    130. % h=bar(X,Y,0.5);
    131. % set(gca,'FontSize',20);%设置坐标轴
    132. % set(gca,'YLim',[0 500]);
    133. % set(gcf,'color','w');
    134. % xlabel('Number of variables(3)','FontSize',25,'FontName','Times Rew Roman');
    135. % ylabel('Current Best individual','FontSize',25,'FontName','Times Rew Roman');
    136. % box off;
    137. % set(gca,'linewidth',1);%坐标轴加粗
    138. % ax1 = axes('Position',get(gca,'Position'),'XAxisLocation','top','YAxisLocation','right','Color','none','XColor','k','YColor','k'); % 设置坐标区
    139. % set(ax1,'XTick', [],'YTick', []); % 去掉xy轴刻度
    140. % set(ax1, 'LineWidth', 1);%加粗线条

  • 相关阅读:
    Golang接收者方法语法糖
    dflow入门2——Slices
    怎么处理zk或redis脑裂
    python使用numpy创建空二维数组,然后再将一维数组添加到二维数组中
    「51媒体」政企宣传邀请媒体的作用?
    数据安全与个人隐私:美国人的焦虑与变化
    SQL(面试实战07)
    springboot下的mybatis打印sql语句
    Qt编写ERP库存库房发货电子看板
    ArcGIS校园3D展示图制作详细教程
  • 原文地址:https://blog.csdn.net/qq_56294106/article/details/138185303