sin
Sine of fixed-point values
Syntax
Description
Examples
Calculate the Sine of Fixed-Point Input Values
theta = fi([-pi/2,-pi/3,-pi/4,0,pi/4,pi/3,pi/2]); y = sin(theta)
y = -1.0000 -0.8661 -0.7072 0 0.7070 0.8659 0.9999 DataTypeMode: Fixed-point: binary point scaling Signedness: Signed WordLength: 16 FractionLength: 15
Input Arguments
theta
— Input angle in radians
real-valued fi
object
Input angle in radians, specified as a real-valued fi
object.
theta
can be a signed or unsigned scalar, vector, matrix, or
multidimensional array containing the fixed-point angle values in radians. Valid data
types of theta
are:
fi
singlefi
doublefi
fixed-point with binary point scalingfi
scaled double with binary point scaling
Data Types: fi
Output Arguments
y
— Sine of input angle
scalar | vector | matrix | multidimensional array
Sine of input angle, returned as a scalar, vector, matrix, or multidimensional
array. y
is a signed, fixed-point number in the range [-1,1].
If the DataTypeMode
property of theta
is
Fixed-point: binary point scaling
, then y
is
returned as a signed fixed-point data type with binary point scaling, a 16-bit word
length, and a 15-bit fraction length (numerictype(1,16,15)
). If
theta
is a fi
single, fi
double, or fi
scaled double with binary point scaling, then
y
is returned with the same data type as
theta
.
More About
Sine
The sine of angle Θ is defined as
Algorithms
The sin
function computes the sine 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.
fimath Propagation Rules
The sin
function ignores and discards any fimath
attached to the input, theta
. The output, y
, is always
associated with the default fimath
.
Extended Capabilities
C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.
Version History
Introduced in R2012a
Commande MATLAB
Vous avez cliqué sur un lien qui correspond à cette commande MATLAB :
Pour exécuter la commande, saisissez-la dans la fenêtre de commande de MATLAB. Les navigateurs web ne supportent pas les commandes 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)