资源描述:
《matlab 多个纵坐标》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、帮找了一个Canadan做的,应该能解决楼主的问题。复制内容到剪贴板代码:function[ax,hlines]=plotyyy(x1,y1,x2,y2,x3,y3,ylabels)%PLOTYYY-Extendsplotyytoincludeathirdy-axis%Syntax: [ax,hlines]=plotyyy(x1,y1,x2,y2,x3,y3,ylabels)%Inputs:x1,y1arethexdataandydataforthefirstaxes'line% x2,y2are
2、thexdataandydataforthesecondaxes'line% x3,y3arethexdataandydataforthethirdaxes'line% ylabelsisa3x1cellarraycontainingtheylabelstrings%Outputs:ax- 3x1doublearraycontainingtheaxes'handles% hlines-3x1doublearraycontainingthelines'handles%Auth
3、or:DenisGilbert,Ph.D.,physicaloceanography%MauriceLamontagneInstitute%Dept.ofFisheriesandOceansCanada%email:gilbertd@dfo-mpo.gc.ca %Web:http://www.qc.dfo-mpo.gc.ca/iml/%April2000;Lastrevision:14-Nov-2001ifnargin==6 ylabels{1}='';ylabels{2}='';ylabels{3}='
4、';elseifnargin>7 error('Toomanyinputarguments')elseifnargin<6 error('Notenoughinputarguments')endfigure('units','normalized',... 'DefaultAxesXMinorTick','on','DefaultAxesYminorTick','on');[ax,hlines(1),hlines(2)]=plotyy(x1,y1,x2,y2);cfig=get(gcf,'color
5、');pos=[0.1 0.1 0.7 0.8];offset=pos(3)/5.5;pos(3)=pos(3)-offset/2;set(ax,'position',pos); pos3=[pos(1)pos(2)pos(3)+offsetpos(4)];limx1=get(ax(1),'xlim');limx3=[limx1(1) limx1(1)+1.2*(limx1(2)-limx1(1))];ax(3)=axes('Position',pos3,'box','off',... 'Colo
6、r','none','XColor','k','YColor','r',... 'xtick',[],'xlim',limx3,'yaxislocation','right');hlines(3)=line(x3,y3,'Color','r','Parent',ax(3));limy3=get(ax(3),'YLim');line([limx1(2)limx3(2)],[limy3(1)limy3(1)],... 'Color',cfig,'Parent',ax(3),'Clipping','off'
7、);axes(ax(2))set(get(ax(1),'ylabel'),'string',ylabels{1})set(get(ax(2),'ylabel'),'string',ylabels{2})set(get(ax(3),'ylabel'),'string',ylabels{3})实例:在CommondWindow里运行:复制内容到剪贴板代码:x=[00.10.20.30.40.4260.50.60.6880.70.80.91.0];y=[268.95272.36275.07277.07277.932
8、78276.5267.16248.2244.3200.37137.7158.7];a=[00.2250.4080.5660.6930.7180.7760.820.8310.8310.8180.7840.6];k=[2.552.2542.0631.8861.7331.6871.5521.3681.2071.1871.0230.8730.6];ylabels{1}='轴1';ylabels{2}='轴2