How do i plot and label a graph using secondary axis in matlab

3 views (last 30 days)
Hello, I'm trying to plot and label two vertical axes for (A and B) of different scales against the same horizontal axis (U).
U=[1 2 3 4 5 6 7 8];
A=[0.0141 0.0135 0.013 0.0125 0.012 0.0117 0.0113 0.011];
B=[0.142267 0.14271177 0.1430866 0.14334375 0.14357196 0.143885125 0.144042862 0.14423808];

Accepted Answer

Sean de Wolski
Sean de Wolski on 31 Aug 2016
U=[1 2 3 4 5 6 7 8];
A=[0.0141 0.0135 0.013 0.0125 0.012 0.0117 0.0113 0.011];
B=[0.142267 0.14271177 0.1430866 0.14334375 0.14357196 0.143885125 0.144042862 0.14423808];
yyaxis left
plot(U,A)
yyaxis right
plot(U,B)
If you're on an older release without yyaxis, then look at plotyy or upgrade.

More Answers (0)

Categories

Find more on Two y-axis in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!