필터 지우기
필터 지우기

Semilogy with two functions - how to make it work?

조회 수: 12 (최근 30일)
Chris
Chris 2013년 9월 16일
댓글: Connor Williams 2019년 9월 25일
I have two functions, y1 and y2, both of which are quadratic functions. I'm trying to graph them on the same plot, with the y-axis being on a logarithmic scale instead of a linear scale. I know how to get just one of the functions to have a log scale on the y axis, but whenever I have two functions involved, the y-axis reverts to a linear scale. I have the code I've been using below; how might I format the semilogy so that the plot will have both functions graphed while still having the y-axis as a logarithmic scale? Any help would be appreciated.
Code:
x1=0:0.1:50;
x2=0:0.1:50;
y1=15*(x1.^2);
y2=80*(x2.^2);
semilogy(y1,y2)
plot(x1,y1,'-','LineWidth',3,'Color','k')
hold on
plot(x2,y2,'-','LineWidth',3,'Color','k')

답변 (2개)

the cyclist
the cyclist 2013년 9월 16일
x1=0:0.1:50;
x2=0:0.1:50;
y1=15*(x1.^2);
y2=80*(x2.^2);
figure
hold on
semilogy(x1,y1,'-','LineWidth',3,'Color','k')
semilogy(x2,y2,'-','LineWidth',3,'Color','k')
  댓글 수: 1
Connor Williams
Connor Williams 2019년 9월 25일
This is incorrect. If you initiate the figure with figure and hold on commands before the semilogy command, the figure remains with linear axes.

댓글을 달려면 로그인하십시오.


Chris
Chris 2013년 9월 16일
I think that'll work for now, thank you.
  댓글 수: 1
the cyclist
the cyclist 2013년 9월 16일
Just for your future reference, your remark would have been better placed as a "comment" on my answer (rather than as a new "answer"). You might also consider accepting my answer if it was helpful to you, which may be useful for future users looking for something similar.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Graphics Objects에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by