To create a graph with one y axis in the left and another y axis in the right with different limits, you can use the yyaxis
function in Matlab.
Here is an example code snippet that generates such a graph:
main.m262 chars20 lines
In this code, we first generate some sample data (x
, y1
, and y2
).
Next, we create a new figure using figure
. We then use yyaxis left
to set the left y-axis as the active axis for plotting. We plot y1
against x
using plot
, and set the y-axis limits using ylim
. We then add a y-axis label using ylabel
.
We switch to the right y-axis using yyaxis right
and repeat the previous steps with y2
. We also set the limits for the right y-axis and add a label.
Finally, we add an x-axis label and a title to the plot.
This should produce a graph with two y-axes on opposite sides of the plot, with different limits and labels for each.
gistlibby LogSnag