it's just a change-of-base to convert the base of the logarithm, you can just use logm as follows:

log2m=logm(M) ./ log(2);
Answer from bla on Stack Overflow
🌐
MathWorks
mathworks.com › symbolic math toolbox › mathematics › mathematical functions
log2 - Base-2 logarithm of symbolic input - MATLAB
For the syntax [F,E] = log2(X), any zeros in X produce F = 0 and E = 0. Input values of Inf, -Inf, or NaN are returned unchanged in F with a corresponding exponent of E = 0. ... Base-2 logarithm values, returned as a symbolic number, vector, matrix, or array of the same size as X.
🌐
MathWorks
mathworks.com › matlab › mathematics › elementary math › exponents and logarithms
log2 - Base 2 logarithm and floating-point number dissection - MATLAB
Exponent values, returned as a ... X = F.*2.^E. This function corresponds to the ANSI® C function frexp() and the IEEE® floating-point standard function logb(). Any zeros in X produce F = 0 and E = 0. ... The log2 function fully supports tall arrays. For more information, see Tall Arrays.
🌐
MathWorks
mathworks.com › matlabcentral › answers › 1465394-how-do-i-calculate-a-logarithm-of-a-variable-base
How do I calculate a logarithm of a variable base? - MATLAB Answers - MATLAB Central
October 2, 2021 - Hi! I tried to calculate a log of a varying base - no success. I saw that calculating log of the base of 10 or e is possible. for an example: after typing log (a,b) - I recieve an ERROR message. ...
🌐
MathWorks
mathworks.com › matlabcentral › answers › 1853103-base-2-logarithmic-scale-on-bar-diagram
Base-2 logarithmic scale on bar diagram - MATLAB Answers - MATLAB Central
November 16, 2022 - will produce the same relative bar heights as those if you were to mess around with the log2() values and scale them. Sign in to comment. Sign in to answer this question. ... https://www.mathworks.com/matlabcentral/answers/1853103-base-2-logarithmic-scale-on-bar-diagram#answer_1101968
Find elsewhere
🌐
Johns Hopkins University
math.jhu.edu › ~shiffman › 370 › help › techdoc › ref › log2.html
log2 (MATLAB Function Reference)
Description Y = log2(X) computes the base 2 logarithm of the elements of X. [F,E] = log2(X) returns arrays F and E. Argument F is an array of real values, usually in the range 0.5 abs(F) < 1. For real X, F satisfies the equation: X = F.*2.^E.
🌐
Google Groups
groups.google.com › g › comp.soft-sys.matlab › c › iDGOYEoliGw
base 2 logarithm scale plot
http://www.mathworks.com/matlabcentral/fileexchange/16003 · set(gca, 'YScale', 'log', 'XScale', 'log'); set(gca, 'YLim', [1e1 1e3], 'YTick', [1e0 1e1 1e2 1e3]) set(gca, 'XLim', [4 40], 'XTick',[4 8 16 32]); tick2text(gca, 'axis', 'x', 'xformat', @(x) sprintf('2^%d', log2(x))); I just updated tick2text to work properly on logarithmically scaled axes, which I had overlooked in my original version, so you may have to wait a day or two for the updated version to appear on the FEX.
🌐
MathWorks
mathworks.com › matlabcentral › answers › 1802695-how-can-i-take-the-log2-of-x-plus-1-of-a-matrix
How can i take the log2 of x plus 1 of a matrix - MATLAB Answers - MATLAB Central
September 10, 2022 - Y = LOG2(X) is the base 2 logarithm of the elements of X. [F,E] = LOG2(X) for each element of the real array X, returns an array F of real numbers, usually in the range 0.5 <= abs(F) < 1, and an array E of integers, so that X = F .* 2.^E.
🌐
Matlabhelp
matlabhelp.com › home › coding in matlab assignment help › how to code for log base 2 in matlab
How To Code For Log Base 2 In Matlab Matlab Help, Matlab Assignment & Homework Help, Matlab Tutor
April 25, 2022 - As this is not good practice you understand a lot more without understanding this, and you will get it from GitHub in a pretty harsh situation. In the code as I am having it, I can call image:GetFileName() that I have written in here just to get my file name,How To Code For Log Base 2 In Matlab The code for logging base command can be looked at here!
🌐
Scilab
help.scilab.org › docs › 5.4.1 › en_US › m2sci_log2.html
log2 (Matlab function) - Base 2 logarithm and dissect floating point number
April 2, 2013 - Please note that the recommended version of Scilab is 2026.0.1. This page might be outdated. However, this page did not exist in the previous stable version. Scilab help >> Matlab to Scilab Conversion Tips > Matlab-Scilab equivalents > L > log2 (Matlab function) Base 2 logarithm and dissect floating point number
🌐
MathWorks
mathworks.com › matlabcentral › answers › 579159-logarithmic-scale-with-a-different-base
Logarithmic scale with a different base - MATLAB Answers - MATLAB Central
August 13, 2020 - https://www.mathworks.com/matlabcentral/answers/579159-logarithmic-scale-with-a-different-base#answer_479331 · Cancel Copy to Clipboard · log2(x) = log(x) *log(2) log(2) is a uniform scaling and since plots are scaled to fit available space, ...
🌐
MathWorks
mathworks.com › fixed-point designer › embedded implementation › function approximation with lookup tables › implement lookup tables in matlab
Implement Fixed-Point Log2 Using Lookup Table - MATLAB & Simulink
1.000000000000000]; % Cast to fixed point with the most accurate rounding method WL = 4*B; % Word length FL = 2*B; % Fraction length LOG2LUT = fi(log2_table,1,WL,FL,'RoundingMethod','Nearest'); % Set fimath for the most efficient math operations F = fimath('OverflowAction','Wrap',... ...
🌐
Narkive
comp.soft-sys.matlab.narkive.com › zIL2lrNV › scale-log-base-2-while-plotting
scale log base 2 while plotting
start = 0; stop = 4; N = 100; xvalues = 2.^ [start+(0:N-2)*(stop-start)/(floor(N)-1), stop]; Note that for any k=2:99 xvalues(k+1)/xvalues(k) is the same. If you want the latter (2nd option), just take log2( ) of the x-axis values as I previously stated.