logarithm of base other than e,10 and 2
조회 수: 370 (최근 30일)
이전 댓글 표시
how do i find logarithms having base other than e, 10 and 2.
댓글 수: 0
채택된 답변
James Tursa
2012년 7월 29일
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
Stephen23
2020년 4월 18일
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).
추가 답변 (4개)
Chris Lucero
2020년 4월 18일
편집: Walter Roberson
2020년 4월 18일
y = logb(magic(3),[1 2 3; 4 5 6; 7 8 9]);
댓글 수: 1
Walter Roberson
2020년 4월 18일
logb appears to refer to the File Exchange contribution https://www.mathworks.com/matlabcentral/fileexchange/14866-logb
Walter Roberson
2020년 4월 18일
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.
댓글 수: 0
lina al noaimi
2022년 2월 26일
how do we convert from base 9 to base 12 in matlab
can you give me an example on it
댓글 수: 1
Walter Roberson
2022년 2월 26일
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)
참고 항목
카테고리
Help Center 및 File Exchange에서 Exponents and Logarithms에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!