当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


MATLAB plotyy()用法及代码示例


它在左侧和右侧创建带有 y-axes 的图形。

用法

plotyy(X1,Y1,X2,Y2) //   It plots X1 versus Y1 with y-axis label on the left and plot X2 versus Y2 with y-axis labeling on the right.
plotyy(X1,Y1,X2,Y2,'function') // It uses the plotting function specified by the string 'function' instead of plot to produce each graph. 'function' can be plot, semilogx, semilogy,stem,loglog etc.
plotyy(X1, Y1,X2,Y2,'function1','function2') // It uses function1(X1, Y1) to plot the information for the left-axis and function2(X2,Y2) to plot the information for the right axis.
[AX, H1, H2] = plotyy(...) // It returns the handles of the two axes generated in AX and the handle of the graphics objects from each plots in H1 and H2. AX (1) is a left axes and AX (2) is a right axes.

示例

y_1=e^-x sinx,0≤t≤10
y_2=e^x
x= 1:1:10;
y1=exp(-x).*sin(x);
y2=exp(x);
Ax=plotyy(x, y1, x, y2);
hy1=get(Ax(1),'ylabel');
hy2= get(Ax(2),'ylabel');
set(hy1,'string','e^-x sin(x)');
set(hy2,'string',' e^ x');

输出:

MATLAB plotyy()



相关用法


注:本文由纯净天空筛选整理自 MATLAB plotyy()。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。