필터 지우기
필터 지우기

Curve in matlab plotting

조회 수: 2 (최근 30일)
Amy Topaz
Amy Topaz 2022년 4월 2일
댓글: Riccardo Scorretti 2022년 4월 2일
How to plot the curve of the below points with the y axis as ln(y) instead of y. So taking the ln values of all y1 and y2 points and then plotting. Also need to indicate the points on the curve.
X Y1 Y2
57 78.2 165.1
87 67.06 101.8
107 64.66 88.7
257 61.43 63.58
507 61.45 61.47
1007 60.51 60.91

답변 (1개)

Riccardo Scorretti
Riccardo Scorretti 2022년 4월 2일
편집: Riccardo Scorretti 2022년 4월 2일
Dear Amy,
if I understand correctly your question, you can use semilogy instead of plot:
data = [ ...
57 78.2 165.1 ; ...
87 67.06 101.8 ; ...
107 64.66 88.7 ; ...
257 61.43 63.58 ; ...
507 61.45 61.47 ; ...
1007 60.51 60.91 ];
x = data(:,1) ; y1 = data(:,2) ; y2 = data(:,3);
% Here we go ...
figure
semilogy(x, y1, 'o-', x, y2, 's-');
grid on ; legend('y1', 'y2');
xlabel('x') ; ylabel('y');
  댓글 수: 2
Amy Topaz
Amy Topaz 2022년 4월 2일
Thank you.
The y axis is ln(y) and not log base 10 y. How to do that?
Riccardo Scorretti
Riccardo Scorretti 2022년 4월 2일
Well, in this case I'm afraid you have to to "by hand", but the grid will not be that nice:
data = [ ...
57 78.2 165.1 ; ...
87 67.06 101.8 ; ...
107 64.66 88.7 ; ...
257 61.43 63.58 ; ...
507 61.45 61.47 ; ...
1007 60.51 60.91 ];
x = data(:,1) ; y1 = data(:,2) ; y2 = data(:,3);
% Here we go ...
figure
plot(x, log10(y1), 'o-', x, log10(y2), 's-');
grid on ; legend('y1', 'y2');
xlabel('x') ; ylabel('log(y)');

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

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by