Main Content

removefimath

Remove fimath from fi object

Description

y = removefimath(x) returns 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.

example

Examples

collapse all

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

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.

trace-code.png

Input Arguments

collapse all

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

collapse all

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

See Also

| |