Documentation Center

  • Trial Software
  • Product Updates

numerictype

Construct numerictype object

Syntax

T = numerictype
T = numerictype(s)
T = numerictype(s,w)
T = numerictype(s,w,f)
T = numerictype(s,w,slope,bias)
T = numerictype(s,w,slopeadjustmentfactor,fixedexponent,bias)
T = numerictype(property1,value1, ...)
T = numerictype(T1, property1, value1, ...)
T = numerictype('double')
T = numerictype('single')
T = numerictype('boolean')

Description

You can use the numerictype constructor function in the following ways:

  • T = numerictype creates a default numerictype object.

  • T = numerictype(s) creates a numerictype object with Fixed-point: unspecified scaling, Signed property value s, and 16-bit word length.

  • T = numerictype(s,w) creates a numerictype object with Fixed-point: unspecified scaling, Signed property value s, and word length w.

  • T = numerictype(s,w,f) creates a numerictype object with Fixed-point: binary point scaling, Signed property value s, word length w and fraction length f.

  • T = numerictype(s,w,slope,bias) creates a numerictype object with Fixed-point: slope and bias scaling, Signed property value s, word length w, slope, and bias.

  • T = numerictype(s,w,slopeadjustmentfactor,fixedexponent,bias) creates a numerictype object with Fixed-point: slope and bias scaling, Signed property value s, word length w, slopeadjustmentfactor, fixedexponent, and bias.

  • T = numerictype(property1,value1, ...) allows you to set properties for a numerictype object using property name/property value pairs. All properties for which you do not specify a value get assigned their default value.

  • T = numerictype(T1, property1, value1, ...) allows you to make a copy of an existing numerictype object, while modifying any or all of the property values.

  • T = numerictype('double') creates a double numerictype.

  • T = numerictype('single') creates a single numerictype.

  • T = numerictype('boolean') creates a Boolean numerictype.

The properties of the numerictype object are listed below. These properties are described in detail in numerictype Object Properties.

  • Bias — Bias

  • DataType — Data type category

  • DataTypeOverride — Data type override settings. Note that this property is not visible when its value is the default, Inherit.

  • DataTypeMode — Data type and scaling mode

  • FixedExponent — Fixed-point exponent

  • SlopeAdjustmentFactor — Slope adjustment

  • FractionLength — Fraction length of the stored integer value, in bits

  • Scaling — Fixed-point scaling mode

  • Signed — Signed or unsigned

  • Signedness — Signed, unsigned, or auto

  • Slope — Slope

  • WordLength — Word length of the stored integer value, in bits

Examples

Create a default numerictype object

Type

T = numerictype

to create a default numerictype object.

T =
 

          DataTypeMode: Fixed-point: binary point scaling
            Signedness: Signed
            WordLength: 16
        FractionLength: 15

Create a numerictype object with specified word and fraction lengths

The following code creates a signed numerictype object with a 32-bit word length and 30-bit fraction length.

T = numerictype(1, 32, 30)
 T =
 
          DataTypeMode: Fixed-point: binary point scaling
            Signedness: Signed
            WordLength: 32
        FractionLength: 30

Create a numerictype object with unspecified scaling

If you omit the argument f, the scaling is unspecified.

T = numerictype(1, 32)
T =
 
          DataTypeMode: Fixed-point: unspecified scaling
            Signedness: Signed
            WordLength: 32

Create a numerictype object with default word length and scaling

If you omit the arguments w and f, the word length is automatically set to 16 bits and the scaling is unspecified.

T = numerictype(1)
T =
 
          DataTypeMode: Fixed-point: unspecified scaling
            Signedness: Signed
            WordLength: 16

Create a numerictype object with specified property values

You can use property name/property value pairs to set numerictype properties when you create the object.

T = numerictype('Signed', true, 'DataTypeMode',...
 'Fixed-point: slope and bias scaling',...
 'WordLength', 32, 'Slope', 2^-2, 'Bias', 4)
T =
 
          DataTypeMode: Fixed-point: slope and bias scaling
            Signedness: Signed
            WordLength: 32
                 Slope: 0.25
                  Bias: 4

    Note:   When you create a numerictype object using property name/property value pairs, Fixed-Point Designer™ software first creates a default numerictype object, and then, for each property name you specify in the constructor, assigns the corresponding value. This behavior differs from the behavior that occurs when you use a syntax such as T = numerictype(s,w). See Example: Construct a numerictype Object with Property Name and Property Value Pairs in the Fixed-Point Designer User's Guide for more information.

Create a numerictype object with unspecified sign

You can create a numerictype object with an unspecified sign by using property name/property values pairs to set the Signedness property to Auto.

T = numerictype('Signedness', 'Auto')
T =
 

          DataTypeMode: Fixed-point: binary point scaling
            Signedness: Auto
            WordLength: 16
        FractionLength: 15

    Note:   Although you can create numerictype objects with an unspecified sign (Signedness: Auto), all fi objects must have a Signedness of Signed or Unsigned. If you use a numerictype object with Signedness: Auto to construct a fi object, the Signedness property of the fi object automatically defaults to Signed.

Create a numerictype object with specified data type

You can create a numerictype object with a specific data type by including the property name/property value pair in the numerictype constructor.

T = numerictype(false, 24, 12, 'DataType', 'ScaledDouble')
 T =
 

          DataTypeMode: Scaled double: binary point scaling
            Signedness: Unsigned
            WordLength: 24
        FractionLength: 12

MATLAB® returns an unsigned numerictype object, T, with the specified WordLength of 24, FractionLength of 12, and with DataType set to ScaledDouble.

See Also

| | |

Related Examples

Was this topic helpful?