MATLAB Answers

could anyone help me how to avoid the repetition of y axis values on the right with respect to the following code

1 view (last 30 days)
jaah navi
jaah navi on 21 Mar 2020
Answered: Rui Wang Wang on 21 Mar 2020
Code:
x=1:5
y1=[ 3.5743 2.4635 1.6621 1.3403 0.5476 ];
y2=[3890000 4168000 4446000 4724000 4999000 ]
y3=[ 1.5543 1.1435 0.6421 0.2303 0.1476 ];
y4=[4190000 4454000 4718000 4982000 5346000 ]
figure
[hAx,hLine1,hLine2] = plotyy(x, y1, x, y2,@(X,Y)semilogy(X,Y,'k'), @(X,Y)plot(X,Y,'k'))
hold on;
[hAx,hLine3,hLine4] = plotyy(x, y3, x, y4,@(X,Y)semilogy(X,Y,'k'), @(X,Y)plot(X,Y,'k'))
wheni run i can get the graph but y axis values on the right is occuring more than once.
Could anyone please help me how to avoid it.

  0 Comments

Sign in to comment.

Answers (1)

Rui Wang Wang
Rui Wang Wang on 21 Mar 2020
%Make the scale range of the two graphs equal , I added four "set" to set the scale , and i suggest you set different colors .
x=1:5
y1=[ 3.5743 2.4635 1.6621 1.3403 0.5476 ];
y2=[3890000 4168000 4446000 4724000 4999000 ]
y3=[ 1.5543 1.1435 0.6421 0.2303 0.1476 ];
y4=[4190000 4454000 4718000 4982000 5346000 ]
figure
[hAx1,hLine1,hLine2] = plotyy(x, y1, x, y2,@(X,Y)semilogy(X,Y,'k'), @(X,Y)semilogy(X,Y,'k'));
set(hAx1(1),'ylim',[0 5]);
set(hAx1(2),'ylim',[3890000 5346000 ]);
hold on;
[hAx2,hLine3,hLine4] = plotyy(x, y3, x, y4,@(X,Y)semilogy(X,Y,'k'), @(X,Y)semilogy(X,Y,'k'));
set(hAx2(1),'ylim',[0 5]);
set(hAx2(2),'ylim',[3890000 5346000 ]);

  0 Comments

Sign in to comment.

Sign in to answer this question.

Tags