Log base 2 of symbolic input
log2(x)
example
log2(x) returns the logarithm to the base 2 of x. If x is an array, log2 acts element-wise on x.
x
2
log2
collapse all
Compute the log base 2 of numeric input.
log2(20)
ans = 4.3219
Compute the log base 2 of symbolic input. The result is in terms of log.
log
syms x f = x^2; fLog2 = log2(f)
fLog2 = log(x^2)/log(2)
Convert symbolic output to double by substituting for x with a number by using subs, and then using double.
subs
double
fLog2 = subs(fLog2,x,5); % x is 5 fLog2 = double(fLog2)
fLog2 = 4.6439
Input, specified as a number, vector, matrix, or array, or a symbolic number, variable, array, function, or expression.
log | log10
log10