%% Add Second y-Axis to Specific Axes
% Starting in R2019b, you can display a tiling of plots using the tiledlayout and nexttile functions. Call the tiledlayout function to create a 2-by-1 tiled chart layout. Call the nexttile function to create the axes objects ax1 and ax2. Add a second y-axis to the top axes by specifying ax1 as the first input to yyaxis. If you do not specify the axes, then yyaxis adds a second y-axis to the current axes.

x = linspace(1,10);
tiledlayout(2,1)

% Top plot
ax1 = nexttile;
yyaxis(ax1,'left')
plot(ax1,x,sin(x))
yyaxis(ax1,'right')
plot(ax1,x,exp(x))

% Bottom plot
ax2 = nexttile;
plot(ax2,1:10)

% Copyright 2019 The MathWorks, Inc.