下面是绘制双坐标图像的一个小程序,运用了plot函数来绘制,它的调用方式如下面所列举
plotyy(X1,Y1,X2,Y2)
plotyy(X1,Y1,X2,Y2,function)
plotyy(X1,Y1,X2,Y2,'function1','function2')
[AX,H1,H2] = plotyy(...)
这些来自软件本身的帮助文件,帮助文件相关的介绍挺详细,可以仔细地看看。
源程序如下
这个描述了两个函数,还定义了X和Y轴的坐标参数
figure
x = 0::20;
y1 = 200*exp(-*x).*sin(x);
y2 = *exp(-*x).*sin(10*x);
[AX,H1,H2] = plotyy(x,y1,x,y2,'plot');
>> set(get(AX(1),'Ylabel'),'String','Slow Decay')
set(get(AX(2),'Ylabel'),'String','Fast Decay')
程序略作改动
set(H1,'LineStyle','--')
set(H2,'LineStyle',':')
>> figure
x = 0::20;
y1 = 200*exp(-*x).*sin(x);
y2 = *exp(-*x).*sin(10*x);
[AX,H1,H2] = plotyy(x,y1,x,y2,'plot');
set(get(AX(1),'Ylabel'),'String','Slow Decay')
set(get(AX(2),'Ylabel'),'String','Fast Decay')
xlabel('Time (\musec)')
title('Multiple Decay Rates'); set(H1,'LineStyle','--')
set(H2,'LineStyle',':')
运行结果如下图
Matlab绘制双坐标的程序实例 来自淘豆网m.daumloan.com转载请标明出处.