matlab中双纵轴做图

一篇不错的latex公式:https://www.luogu.com.cn/article/1gxob6zc

matlab中双纵轴做图:

t=linspace(0,3*pi,200);
    y=sin(t);
    y1=cos(2*t);
    subplot(311)
    plot(t,y);                            %两个参量,第一个为横轴,第二个为纵轴
    title('plot(t,y)');
    grid on
    xlabel('t');
    ylabel('y=sin(t)');
    subplot(312)
    plot(y1);                            %只有一个参量时,将参量下标作为横轴,参量为纵轴
    title('plot(y1)');
    xlabel('t');
    ylabel('y=cos(2*t)');
    grid on
    subplot(313)
    AX=plotyy(t,y,t,y1);                %多个输入向量时,双纵轴做图,自动匹配成组
    title('plotyy(t,y,t,y1)');
    grid on
    xlabel('t');
    ylabel(AX(1),'y=sin(t)');
    ylabel(AX(2),'y=cos(2*t)');

效果:testPlot3

 

posted @ 2026-06-22 20:50  叕叒双又  阅读(9)  评论(0)    收藏  举报