Curve in matlab plotting

1 次查看(过去 30 天)
Amy Topaz
Amy Topaz 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
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
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