下面的代码给出的是我在matlab作图中常用的一些指令,仅提供用作模板,后面如果有更好的方法再更新

%%%parameter%%%

linewidth = 1.5;

fontsize = 14;

%%%attitude and desired attitude%%%

figure1 = figure(1);

subplot(311);plot(attitude.data(15001:75000,7)-30,attitude.data(15001:75000,4),'b','LineWidth',linewidth),hold on;

% plot(attgyr.data(1:26501,7),taratt.data(1:26501,1),'--r','LineWidth',linewidth),legend('\phi','\phi_d','location','northeast');

set(gca,'linewidth',0.5,'fontsize',fontsize,'fontname','Times New Roman');grid on

xlabel('Time (sec)','Fontname', 'Times New Roman','FontSize',fontsize);

ylabel('\phi (deg)','Fontname', 'Times New Roman','FontSize',fontsize);

axes('position',[0.68,0.91,0.15,0.09]); % 生成子图

plot(attitude.data(15001:75000,7)-30,attitude.data(15001:75000,4),'b','LineWidth',linewidth);grid on;

% set(gca, 'YTick', [-10 -5 0 5])

xlim([60 80])

ylim([-1.5 1.5])

annotation(figure1,'rectangle',...

[0.519874476987448 0.806173184357542 0.127615062761506 0.0783333333333347],...

'Color',[1 0 0],...

'LineWidth',1.5,...

'LineStyle','--');

% 创建 arrow

annotation(figure1,'arrow',[0.567085917558873 0.633299839460402],...

[0.895648044692737 0.952513966480447]);

subplot(312);plot(attitude.data(15001:75000,7)-30,attitude.data(15001:75000,5),'b','LineWidth',linewidth),hold on;

% plot(attgyr.data(1:26501,7),taratt.data(1:26501,2),'--r','LineWidth',linewidth),legend('\theta','\theta_d');

set(gca,'linewidth',0.5,'fontsize',fontsize,'fontname','Times New Roman');grid on

% xlim([0 265])

ylim([-20 20])

xlabel('Time (sec)','Fontname', 'Times New Roman','FontSize',fontsize);

ylabel('\theta (deg)','Fontname', 'Times New Roman','FontSize',fontsize);

axes('position',[0.68,0.61,0.15,0.09]); % 生成子图

plot(attitude.data(15001:75000,7)-30,attitude.data(15001:75000,5),'b','LineWidth',linewidth);grid on;

% set(gca, 'YTick', [-10 -5 0 5])

xlim([60 80])

ylim([-1.5 1.5])

annotation(figure1,'arrow',[0.561978101936869 0.624796438099858],...

[0.605145251396649 0.659217877094972]);

annotation(figure1,'rectangle',...

[0.518173796715339 0.510083798882682 0.127615062761506 0.0783333333333347],...

'Color',[1 0 0],...

'LineWidth',1.5,...

'LineStyle','--');

subplot(313);plot(attitude.data(15001:75000,7)-30,attitude.data(15001:75000,6),'b','LineWidth',linewidth),hold on;

% plot(attgyr.data(1:26501,7),taratt.data(1:26501,3),'--r','LineWidth',linewidth),legend('\psi','\psi_d');

set(gca,'linewidth',0.5,'fontsize',fontsize,'fontname','Times New Roman');grid on

xlabel('Time (sec)','Fontname', 'Times New Roman','FontSize',fontsize);

ylabel('\psi (deg)','Fontname', 'Times New Roman','FontSize',fontsize);

% set(gca, 'YTick', [-8 -4 0 4 8])

% xlim([0 265])

ylim([-120 100])

axes('position',[0.68,0.31,0.15,0.09]); % 生成子图

plot(attitude.data(15001:75000,7)-30,attitude.data(15001:75000,6),'b','LineWidth',linewidth);grid on;

% set(gca, 'YTick', [-10 -5 0 5])

xlim([60 80])

ylim([-1 1])

annotation(figure1,'arrow',[0.563681669611817 0.623104420036266],...

[0.309055865921788 0.365921787709497]);

annotation(figure1,'rectangle',...

[0.514772436171121 0.213994413407822 0.127615062761506 0.0783333333333348],...

'Color',[1 0 0],...

'LineWidth',1.5,...

'LineStyle','--');

savefig('Case1attitude.fig')

print -depsc2 Case1attitude

Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐