cos
Cosine of fi
object in radians
Syntax
Description
Examples
Cosine of Fixed-Point Angles
Calculate the cosine of fixed-point input values.
X = fi([0,pi/4,pi/3,pi/2,(2*pi)/3,(3*pi)/4,pi])
X = 0 0.7854 1.0472 1.5708 2.0944 2.3562 3.1416 DataTypeMode: Fixed-point: binary point scaling Signedness: Signed WordLength: 16 FractionLength: 13
Y = cos(X)
Y = 1.0000 0.7072 0.4999 0.0001 -0.4999 -0.7070 -1.0000 DataTypeMode: Fixed-point: binary point scaling Signedness: Signed WordLength: 16 FractionLength: 15
Input Arguments
X
— Input angle in radians
scalar | vector | matrix | multidimensional array
Input angle in radians, specified as a scalar, vector, matrix, or multidimensional array.
X
can be a real-valued, signed or unsigned:
fi
singlefi
doublefi
fixed-point with binary-point scalingfi
scaled double with binary-point scaling
Example: X = fi([pi pi/6],1,8);
Data Types: fi
Output Arguments
Y
— Cosine of input angle
scalar | vector | matrix | multidimensional array
Cosine of input angle, returned as a real-valued fi
scalar,
vector, matrix, or multidimensional array.
More About
Cosine
The cosine of angle Θ is defined as
Algorithms
The cos
function computes the cosine of fixed-point input using an
8-bit lookup table as follows:
Perform a modulo 2π, so the input is in the range [0,2π) radians.
Cast the input to a 16-bit stored integer value, using the 16 most-significant bits.
Compute the table index, based on the 16-bit stored integer value, normalized to the full
uint16
range.Use the 8 most-significant bits to obtain the first value from the table.
Use the next-greater table value as the second value.
Use the 8 least-significant bits to interpolate between the first and second values, using nearest-neighbor linear interpolation.
Extended Capabilities
C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.
Version History
Introduced in R2012a
Apri esempio
Si dispone di una versione modificata di questo esempio. Desideri aprire questo esempio con le tue modifiche?
Comando MATLAB
Hai fatto clic su un collegamento che corrisponde a questo comando MATLAB:
Esegui il comando inserendolo nella finestra di comando MATLAB. I browser web non supportano i comandi MATLAB.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)