double
Converts values to double precision.
Category: Language Fundamentals > Data Types
Syntax
B = double(A)
Returns A as a double array.
Description
double is the default numeric class in MATLAB, with about 15 to 16 significant decimal digits. Converting from single keeps the exact value of the single, which is why double(single(0.1)) is not exactly 0.1. Integers convert exactly, and true and false become 1 and 0.
A char vector becomes the codes of its characters: double('hi') is [104 105]. A string scalar is not a number list: double("12") converts the text to the number 12, and non-numeric text gives NaN. A cell array is an error.
Input arguments
A- Numeric, logical or char array (also datetime, duration and others that define the conversion).
Output arguments
B- Double array of the same size. Characters become their character codes.
Example
Integers, text and logicals
double(int8(-5))
double('hi')
double(true)
double("a")
double(uint8(200)) * 2
Output
ans = -5
ans = 1×2
104 105
ans = 1
ans = NaN
ans = 400