주요 콘텐츠

log

R2026b

Natural logarithm for fixed-point data

Since R2026b

Description

Y = log(X) returns the natural logarithm (base e) of each element of the fixed-point input X.

Note

For the floating-point natural logarithm, use the log function.

example

Examples

collapse all

Create a signed fixed-point number and evaluate the natural logarithm.

x = fi(2,1,16,10);
y = log(x)
y = 

         0.693145751953125
      numerictype(1,43,33)

Create a fixed-point vector of positive values and evaluate the element-wise natural logarithm.

X = fi([0.5 1 2 5 10],1,16,12)';
Y = log(X)
Y = 

        -0.693145751953125
                         0
         0.693145751953125
          1.60943586844951
          2.07940552616492
      numerictype(1,43,33)

Input Arguments

collapse all

Fixed-point input array, specified as a scalar, vector, matrix, or multidimensional array. X must be a positive, real-valued fi object with binary-point scaling.

Data Types: fi

Output Arguments

collapse all

Natural logarithm values, returned as a scalar, vector, matrix, or multidimensional array. The output Y is a signed fi object with the same dimensions as X. The output word length and fraction length are determined automatically based on the input type to preserve the precision and range of the result.

Data Types: fi

Extended Capabilities

expand all

C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.

Version History

Introduced in R2026b

See Also

| | | |