MATLAB 之绘双轴曲线
MATLAB代码 %傻瓜式繁琐 -_-
x = 0:0.01:15;
y1 = 100exp(-0.08x).sin(x);
y2 = 0.8exp(-0.3*x).sin(5x);
figure(1);
[hAx,hLine1,hLine2] = plotyy(x,y1,x,y2);
%曲线类型
hLine2.LineStyle = ‘:’;
hLine1.LineStyle = ‘-.’;
%曲线线宽
hLine1.LineWidth = 2;
hLine2.LineWidth = 2;
%曲线颜色
hLine2.Color = ‘r’;
hLine1.Color = ‘b’;
%两个坐标颜色
set(hAx(2), ‘YColor’, ‘k’);
set(hAx(1), ‘YColor’, ‘k’);
%两个坐标轴刻度字体大小
set(hAx(2),‘fontsize’,12);
set(hAx(1),‘fontsize’,12);
xlabel(‘t’);
ylabel(hAx(2),‘100exp(-0.08x).sin(x)’);
ylabel(hAx(1),'0.8exp(-0.3*x).sin(5x)’);
title(‘双轴曲线’);
legend(‘y1’,‘y2’);