Plotyy using curves with different sizes

1 view (last 30 days)
Josh
Josh on 29 Jun 2017
Answered: Walter Roberson on 29 Jun 2017
I am trying to create a figure with multiple curves on the left axis and one curve on the right axis. The curves on the left axis each have their own set of x values.
I can plot all the data on the figure using the code below, but it connects the ends of each curve so there are extra lines I don't want.
figure
x=0:0.1:10;
x2=0:0.2:10;
y1=-x;
y2=5*x2.^2/1000;
y3=1.2*x.^2/1000;
[hAx,hLine1,hLine2] = plotyy([x2,x],[y2,y3],x,y1,'plot','plot');
Using the suggestion in this answer(https://www.mathworks.com/matlabcentral/answers/243650-plotyy-making-extra-lines) I am getting an error using horizcat dimensions of matrices being concatenated are not consistent, and nothing plots. Is there a way I can successfully plot the above using plotyy?
Using version R2015b
Thanks

Answers (1)

Walter Roberson
Walter Roberson on 29 Jun 2017
[hAx,hLine1,hLine2] = plotyy([x2,nan,x], [y2,nan,y3], x, y1, 'plot', 'plot');

Categories

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

Tags

Products

Community Treasure Hunt

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

Start Hunting!