Plotyy using curves with different sizes

조회 수: 1 (최근 30일)
Josh
Josh 2017년 6월 29일
답변: Walter Roberson 2017년 6월 29일
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

답변 (1개)

Walter Roberson
Walter Roberson 2017년 6월 29일
[hAx,hLine1,hLine2] = plotyy([x2,nan,x], [y2,nan,y3], x, y1, 'plot', 'plot');

카테고리

Help CenterFile Exchange에서 Two y-axis에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by