MATLAB软件画图,如何对双Y轴分别进行说明?

2025-06-20 14:43:29
推荐回答(2个)
回答1:

例子,详见doc plotyy
x = 0:0.01:20;
y1 = 200*exp(-0.05*x).*sin(x);
y2 = 0.8*exp(-0.5*x).*sin(10*x);
[AX,H1,H2] = plotyy(x,y1,x,y2,'plot');
set(get(AX(1),'Ylabel'),'String','Left Y-axis')
set(get(AX(2),'Ylabel'),'String','Right Y-axis')
xlabel('Zero to 20 \musec.')
title('Labeling plotyy')
set(H1,'LineStyle','--')
set(H2,'LineStyle',':')

回答2:

set(get(ax(1),'ylabel'),'string','这是Y的左边');
set(get(ax(2),'ylabel'),'string','这是Y的右边');