Main Content

isequal

Determine whether real-world values of two fi objects are equal, or determine whether properties of two fimath, numerictype, or quantizer objects are equal

Description

example

y = isequal(a,b,…) returns logical 1 (true) if all the fi object inputs have the same real-world value. Otherwise, it returns logical 0 (false).

In relational operations comparing a floating-point value to a fixed-point value, the floating-point value is cast to the same word length and signedness as the fi object, with best-precision scaling.

example

y = isequal(F,G,…) returns logical 1 (true) if all the fimath object inputs have the same properties. Otherwise, it returns logical 0 (false).

example

y = isequal(T,U,…) returns logical 1 (true) if all the numerictype object inputs have the same properties. Otherwise, it returns logical 0 (false).

example

y = isequal(q,r,…) returns logical 1 (true) if all the quantizer object inputs have the same properties. Otherwise, it returns logical 0 (false).

Examples

collapse all

Use the isequal function to determine if two fi objects have the same real-world value.

format long
a = fi(pi)
a = 
   3.141601562500000

          DataTypeMode: Fixed-point: binary point scaling
            Signedness: Signed
            WordLength: 16
        FractionLength: 13
b = fi(pi,1,32)
b = 
   3.141592653468251

          DataTypeMode: Fixed-point: binary point scaling
            Signedness: Signed
            WordLength: 32
        FractionLength: 29
y = isequal(a,b)
y = logical
   0

Input a has a 16-bit word length, while input b has a 32-bit word length. The isequal function returns 0 because the two fi objects do not have the same real-world value.

When comparing a double to a fi object, the double is cast to the same word length and signedness of the fi object.

a = fi(pi);
b = pi;
y = isequal(a,b)
y = logical
   1

The isequal function casts b to the same word length as a, and returns 1. This behavior allows relational operations to work between fi objects and floating-point constants without introducing floating-point values in generated code.

Use the isequal function to determine if two fimath objects have the same properties.

F = fimath('OverflowAction','Saturate','RoundingMethod','Convergent');
G = fimath('RoundingMethod','Convergent','ProductMode','FullPrecision');
y = isequal(F,G)
y = logical
   1

Use the isequal function to determine if two numerictype objects have the same properties.

T = numerictype;
U = numerictype(true, 16, 15);
y = isequal(T,U)
y = logical
   1

Use the isequal function to determine if two quantizer objects have the same properties.

q = quantizer('fixed', [5 4]);
r = quantizer('fixed', 'floor', 'saturate', [5 4]);
y = isequal(q,r)
y = logical
   1

Input Arguments

collapse all

fi objects to be compared, specified as a scalar, vector, matrix, or multidimensional array.

Data Types: fi
Complex Number Support: Yes

fimath objects to be compared.

numerictype objects to be compared, specified as a scalar, vector, matrix, or multidimensional array.

quantizer objects to be compared.

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.

HDL Code Generation
Generate VHDL, Verilog and SystemVerilog code for FPGA and ASIC designs using HDL Coder™.

Version History

Introduced before R2006a