removefimath
Remove fimath object from fi
object
Syntax
Description
returns
a y
= removefimath(x
)fi
object y
with x
’s numerictype
and
value, and no fimath object attached. You can use this function as y
= removefimath(y)
, which gives you localized control over
the fimath settings. This function also is useful for preventing errors
about embedded.fimath
of both operands needing to
be equal.
Examples
Remove fimath Object from fi Object
This example shows how to define a fi
object, define a fimath object, attach the fimath
object to the fi
object and then, remove the attached fimath
object.
a = fi(pi)
a = 3.1416 DataTypeMode: Fixed-point: binary point scaling Signedness: Signed WordLength: 16 FractionLength: 13
f = fimath('RoundingMethod','Floor','OverflowAction','Wrap'); a = setfimath(a,f)
a = 3.1416 DataTypeMode: Fixed-point: binary point scaling Signedness: Signed WordLength: 16 FractionLength: 13 RoundingMethod: Floor OverflowAction: Wrap ProductMode: FullPrecision SumMode: FullPrecision
b = removefimath(a)
b = 3.1416 DataTypeMode: Fixed-point: binary point scaling Signedness: Signed WordLength: 16 FractionLength: 13
Set and Remove fimath for Code Generation
Use the pattern x = setfimath(x,f)
and y
= removefimath(y)
to insulate variables from fimath
settings
outside the function. This pattern does not create copies of the data
in generated code.
function y = fixed_point_32bit_KeepLSB_plus_example(a,b) f = fimath('OverflowAction','Wrap',... 'RoundingMethod','Floor',... 'SumMode','KeepLSB',... 'SumWordLength',32); a = setfimath(a,f); b = setfimath(b,f); y = a + b; y = removefimath(y); end
If you have the MATLAB® Coder™ product, you can generate C code. This example generates C code on a computer with 32-bit, native integer type.
a = fi(0,1,16,15); b = fi(0,1,16,15); codegen -config:lib fixed_point_32bit_KeepLSB_plus_example... -args {a,b} -launchreport
int fixed_point_32bit_KeepLSB_plus_example(short a, short b) { return a + b; }
Input Arguments
x
— Input data
fi object | built-in integer | double | single
Input data, specified as a fi
object or built-in
integer, from which to copy the data type and value to the output. x
must
be a fi
object or an integer data type (int8
, int16
, int32
, int64
, uint8
, uint16
, uint32
,
or uint64
). If x
is not a
fi object or integer data type, then y
= x
.
Output Arguments
y
— Output fi object
fi object | built-in integer | double | single
Output fi object, returned as a fi
object
with no fimath object attached. The data type and value of the output
match the input. If the input, x
, is not a fi
object y
= x
.
Extended Capabilities
C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.
Version History
Introduced in R2012b
Abrir ejemplo
Tiene una versión modificada de este ejemplo. ¿Desea abrir este ejemplo con sus modificaciones?
Comando de MATLAB
Ha hecho clic en un enlace que corresponde a este comando de MATLAB:
Ejecute el comando introduciéndolo en la ventana de comandos de MATLAB. Los navegadores web no admiten comandos de 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)