Curve in matlab plotting
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
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
0 Commenti
Risposte (1)
Riccardo Scorretti
il 2 Apr 2022
Modificato: Riccardo Scorretti
il 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 Commenti
Riccardo Scorretti
il 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)');
Vedere anche
Categorie
Scopri di più su Line Plots in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!