Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

single

Single-precision arrays

Description

Single-precision variables in MATLAB® are stored as 4-byte (32-bit) floating-point values of data type (class) single. For example:

y = single(10);
whos y
Name      Size            Bytes  Class     Attributes

  y         1x1                 4  single              

For more information on floating-point values, see Floating-Point Numbers.

Creation

If you have an array of a different type, such as double or int8, then you can convert that array to single precision using the single function.

Syntax

Y = single(X)

Description

example

Y = single(X) converts the values in X to single precision.

Input Arguments

expand all

Input array, specified as a scalar, vector, matrix, or multidimensional array.

Data Types: double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | logical | char

Examples

expand all

Convert a double-precision variable to single precision with the single function.

x = 100;
xtype = class(x)
xtype = 
'double'
y = single(x)
y = single
    100

Extended Capabilities

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

Introduced before R2006a

Was this topic helpful?