Curve in matlab plotting

1 vue (au cours des 30 derniers jours)
Amy Topaz
Amy Topaz le 2 Avr 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

Réponses (1)

Riccardo Scorretti
Riccardo Scorretti le 2 Avr 2022
Modifié(e) : Riccardo Scorretti le 2 Avr 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 commentaires
Amy Topaz
Amy Topaz le 2 Avr 2022
Thank you.
The y axis is ln(y) and not log base 10 y. How to do that?
Riccardo Scorretti
Riccardo Scorretti le 2 Avr 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)');

Connectez-vous pour commenter.

Catégories

En savoir plus sur Graphics Performance dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by