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 OverflowVideos
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);
For a scalar x,
log2(x) = log(x)/log(2)
I see no reason why this wouldn't work with matrix logarithms: logm(m)/log(2).
For example, let's take the matrix from this example on Wikipedia:
issimilar = @(x,y) all( abs(x(:)-y(:)) < 1e-14 );
m = [1.25, 0.75; 0.75, 1.25];
issimilar( exp(1)^logm(m), m ) % returns true
issimilar( 2^(logm(m)/log(2)), m ) % also returns true
Consider this example:
%# some random data
x = 2.^(0:10);
y = rand(size(x));
plot(log2(x), y) %# plot on log2 x-scale
set(gca, 'XTickLabel',[]) %# suppress current x-labels
xt = get(gca, 'XTick');
yl = get(gca, 'YLim');
str = cellstr( num2str(xt(:),'2^{%d}') ); %# format x-ticks as 2^{xx}
hTxt = text(xt, yl(ones(size(xt))), str, ... %# create text at same locations
'Interpreter','tex', ... %# specify tex interpreter
'VerticalAlignment','top', ... %# v-align to be underneath
'HorizontalAlignment','center'); %# h-aligh to be centered

You can plot directly using the plot command
plot (log2(x), y)
but then your x ticks will be the logarithm rather than the actual value. You could either just change your label
xlabel('Log (base 2) of quantity X');
or you can redo the ticks manually.
xt = get(gca, 'XTick');
set (gca, 'XTickLabel', 2.^xt);
Or you can be really fancy
xticks = 10:25;
set(gca, 'XTick', xticks);
for j = 1:length(xticks)
xtl{j} = ['2^' num2str(xticks(j))];
end
set(gca, 'XTickLabel', xtl)
which will evenly space the tick marks on the log scale, and label them according to their power of 2
I think this can answer your question. https://youtu.be/2s3aJfRr9gE?t=284 Claude Shannon was using bits (log base 2) because he was using the uncertainty of a fair coin flip
I would wager for the exact same reason we use base 10 for common log, the nonfractional part tells you the length in bits (for base 10 it tells you the number of digits). Not to mention the fact that computers generally do math more native in binary. As is mentioned in the comments, all logarithms are just a constant multiple of each other, so it is really up to taste.