Curve in matlab plotting

1 Ansicht (letzte 30 Tage)
Amy Topaz
Amy Topaz am 2 Apr. 2022
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

Antworten (1)

Riccardo Scorretti
Riccardo Scorretti am 2 Apr. 2022
Bearbeitet: Riccardo Scorretti am 2 Apr. 2022
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 Kommentare
Amy Topaz
Amy Topaz am 2 Apr. 2022
Thank you.
The y axis is ln(y) and not log base 10 y. How to do that?
Riccardo Scorretti
Riccardo Scorretti am 2 Apr. 2022
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)');

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Graphics Performance finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by