MATLAB Programming Fundamentals - MathWorks
Creating Integer Data MATLAB stores numeric data as double-precision floating point (double) by default. To store data as an int ...
Arithmetic operations that involve both integers and floating-point always result in an integer data type. MATLAB rounds the res ...
ans = uint32 Integers or integer arrays and scalar double-precision floating-point numbers. This yields a result that has the s ...
x = int8(300) x = int8 127 x = int8(-300) x = int8 -128 Also, when the result of an arithmetic operation involving integers exce ...
Floating-Point Numbers In this section... “Double-Precision Floating Point” on page 4-7 “Single-Precision Floating Point” on pag ...
Bits Usage 30 to 23 Exponent, biased by 127 22 to 0 Fraction f of the number 1.f Because MATLAB stores numbers of type single us ...
You can convert other numeric data, characters or strings, and logical data to double precision using the MATLAB function, doubl ...
Double-Precision Operations You can perform basic arithmetic operations with double and any of the following other classes. When ...
Largest and Smallest Values for Floating-Point Classes For the double and single classes, there is a largest and smallest number ...
Numbers larger than realmax('single') or smaller than -realmax('single') are assigned the values of positive and negative infini ...
The value of eps(x) depends on x. This example shows that, as x gets larger, so does eps(x): eps(50) ans = 7.105427357601002e-15 ...
single 2.3842e-07 Avoiding Common Problems with Floating-Point Arithmetic Almost all operations in MATLAB are performed in doubl ...
b == c ans = logical 0 There are gaps between floating-point numbers. As the numbers get larger, so do the gaps, as evidenced by ...
y = A\b; Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.110223e-16. These are only a ...
Complex Numbers Creating Complex Numbers Complex numbers consist of two separate parts: a real part and an imaginary part. The b ...
Infinity and NaN In this section... “Infinity” on page 4-18 “NaN” on page 4-18 Infinity MATLAB represents infinity by the specia ...
NaN You can also create NaNs by: x = NaN; whos x Name Size Bytes Class x 1x1 8 double The NaN function returns one of the IEEE a ...
NaN ~= NaN ans = 1 4 Numeric Classes ...
Identifying Numeric Classes You can check the data type of a variable x using any of these commands. Command Operation whos x Di ...
Display Format for Numeric Values In this section... “Default Display” on page 4-22 “Display Format Examples” on page 4-22 “Sett ...
«
4
5
6
7
8
9
10
11
12
13
»
Free download pdf