log2

Log base 2 of symbolic input

Syntax

Description

example

log2(x) returns the logarithm to the base 2 of x. If x is an array, log2 acts element-wise on x.

Examples

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.

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.

fLog2 = subs(fLog2,x,5);        % x is 5
fLog2 = double(fLog2)
fLog2 =
    4.6439

Input Arguments

collapse all

Input, specified as a number, vector, matrix, or array, or a symbolic number, variable, array, function, or expression.

See Also

|

Introduced before R2006a