# (i) x-and-y scales defined as "log", or (ii) calculate the log of variables, or (iii) loglog

2 Ansichten (letzte 30 Tage)
Sim am 9 Mai 2023
Kommentiert: Sim am 12 Mai 2023
Are these three methods (and the corresponding plots) equivalent ways to perform the same task ?
% Method 1
figure
axes('XScale', 'log', 'YScale', 'log')
plot(1:10, 1:10)
title('plot(1:10, 1:10), with both x-and-y scales defined as "log"')
% Method 2
figure
plot(log(1:10), log(1:10))
title('plot(log(1:10), log(1:10))')
% Method 3
figure
loglog(1:10, 1:10)
title('loglog(1:10, 1:10)')
##### 0 Kommentare-2 ältere Kommentare anzeigen-2 ältere Kommentare ausblenden

Melden Sie sich an, um zu kommentieren.

### Akzeptierte Antwort

VBBV am 9 Mai 2023
% Method 1
figure
plot(1:10, 1:10)
ax = gca;
% put this after plot call and use as below
set(ax,'XScale', 'log', 'YScale', 'log')
title('plot(1:10, 1:10), with both x-and-y scales defined as "log"')
% Method 2 -->>>> Linear scale but log values of inputs
figure
plot(log(1:10), log(1:10))
title('plot(log(1:10), log(1:10))')
% Method 3
figure
loglog(1:10, 1:10)
title('loglog(1:10, 1:10)')
##### 1 Kommentar-1 ältere Kommentare anzeigen-1 ältere Kommentare ausblenden
VBBV am 9 Mai 2023
Bearbeitet: VBBV am 9 Mai 2023
Method 1 and Method 3 are equivalent but Method 2 is not same as remaining two methods, since Method 2 plots the logarithm of input values on linear scale , while Method 1 uses log scale for plotting linear values, and Method 3 also does same

Melden Sie sich an, um zu kommentieren.

### Weitere Antworten (1)

Antoni Garcia-Herreros am 9 Mai 2023
No,
Method 1 and 3 are equivalent. The X and Y values range from 1 to 10, it does not matter which scale you use, the values remain the same.
% Method 1
subplot(1,3,1)
plot(1:10, 1:10)
title('plot(1:10, 1:10), with both x-and-y scales defined as "log"')
ax=gca;
ax.XScale= 'log'; ax.YScale = 'log';
title('Method 1')
% Method 3
subplot(1,3,3)
loglog(1:10, 1:10)
title('Method 3')
However, in Method 2 the X, Y values change from 0 to 2.3...
% Method 2
subplot(1,3,2)
plot(log(1:10), log(1:10))
title('Method 2')
##### 1 Kommentar-1 ältere Kommentare anzeigen-1 ältere Kommentare ausblenden
Sim am 12 Mai 2023
Thanks a lot both @VBBV and @Antoni Garcia-Herreros for your nice answers! PLease bear in mind that I would accept both of them if I could! :-)

Melden Sie sich an, um zu kommentieren.

### Kategorien

Mehr zu Log Plots finden Sie in Help Center und File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by