logarithm of base other than e,10 and 2

417 Ansichten (letzte 30 Tage)
shahid khan
shahid khan am 29 Jul. 2012
Kommentiert: Walter Roberson am 4 Nov. 2022
how do i find logarithms having base other than e, 10 and 2.

Akzeptierte Antwort

James Tursa
James Tursa am 29 Jul. 2012
logB(X) = logA(X) / logA(B)
You can pick A to be one of the built in functions, like log or log2 or log10. E.g.,
log3(9) = log(9) / log(3) , or
log3(9) = log10(9) / log10(3) , etc.
  1 Kommentar
Stephen23
Stephen23 am 18 Apr. 2020
Note that for many MATLAB versions log10 itself called log2 internally... so you might as well skip the intermediate log10 and just call log2 directly (it is probably more accurate as well).

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (4)

Tsegts
Tsegts am 4 Nov. 2022
how to write that base 3 log

Chris Lucero
Chris Lucero am 18 Apr. 2020
Bearbeitet: Walter Roberson am 18 Apr. 2020
y = logb(magic(3),[1 2 3; 4 5 6; 7 8 9]);

Walter Roberson
Walter Roberson am 18 Apr. 2020
if you really get desparate:
arrayfun(@(V) feval(symengine,'log', B, V), A)
and you might want to double() the result. Note that for this to work, B must be a positive real number, whereas in Jame's solution of log(A)/log(B) then B does not need to be positive and does not need to be real-valued.

lina al noaimi
lina al noaimi am 26 Feb. 2022
how do we convert from base 9 to base 12 in matlab
can you give me an example on it
  1 Kommentar
Walter Roberson
Walter Roberson am 26 Feb. 2022
If you mean numeric base, in the same sense that Hexadecimal representation is base 16 number system, then use base2dec and dec2base.
If you mean log base then log12(x) = log9(x).^(9/12)

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Exponents and Logarithms 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