绘制双y轴的曲线图
x = linspace(0,25);
y = sin(x/2);
[m,n]=size(x);
%% 左侧方向显示绘图
yyaxis left
space=2;% 绘图节点的间隔数
plot(x,y,'.-','MarkerIndices',1:space:n,'MarkerSize',18,'LineWidth',1.5);% MarkerIndices显示需要标记的数据点位置
%% 右侧方向显示绘图
yyaxis right
r = x.^2/2;
plot(x,r,'--*','MarkerIndices',1:4:n,'MarkerSize',8,'LineWidth',1.5);
yyaxis left
title('Plots with Different y-Scales')
xlabel('Values from 0 to 25')
ylabel('Left Side')
yyaxis right
ylabel('Right Side')
set(gcf,'color','w')
set(gca,'fontsize',16,'fontname','Times New Roman','FontWeight','bold');
print(gcf,'-djpeg','-r600',strcat('D:\1.jpg'))
绘图效果