removefimath
Remove fimath
from fi
object
Syntax
Description
returns y
= removefimath(x
)fi
object y
with x
’s
numerictype
and value and with 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
This example shows how to 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.
type fixed_point_32bit_KeepLSB_plus_example.m
function y = fixed_point_32bit_KeepLSB_plus_example(a,b) f = fimath('RoundingMethod', 'Floor', ... 'OverflowAction', 'Wrap', ... 'SumMode', 'KeepLSB', ... 'SumWordLength', 32) a = setfimath(a,f); b = setfimath(b,f); y = a + b; y = removefimath(y); end
a = fi(0,1,16,15); b = fi(0,1,16,15);
You can use MATLAB® Coder™ to generate C code. This example generates C code on a computer with a 32-bit native integer type.
codegen -config:lib fixed_point_32bit_KeepLSB_plus_example... -args {a,b} -launchreport Code generation successful: View report
Trace the code in the code generation report.
Input Arguments
x
— Input data
scalar | vector | matrix | multidimensional array
Input data from which to copy the data type and value to the output, specified as a
scalar, vector, matrix, or multidimensional array. If the input x
is not a fi
object, then y = x
.
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
| fi
Complex Number Support: Yes
Output Arguments
y
— fi
object with no fimath
scalar | vector | matrix | multidimensional array
fi
object with no attached fimath
, returned as
a scalar, vector, matrix, or multidimensional array. The data type and value of the
output match the input. If the input x
is not a
fi
object, then y = x
.
Extended Capabilities
C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.
Version History
Introduced in R2012b
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
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)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)