Programming Fundamentals - The MathWorks - #40

/ 840


catalogue search
P. 01
P. 02
P. 03
P. 04
P. 05
P. 06
P. 07
P. 08
P. 09
P. 10
P. 11
P. 12
P. 13
P. 14
P. 15
P. 16
P. 17
P. 18
P. 19
P. 20
P. 21
P. 22
P. 23
P. 24
P. 25
P. 26
P. 27
P. 28
P. 29
P. 30
P. 31
P. 32
P. 33
P. 34
P. 35
P. 36
P. 37
P. 38
P. 39
P. 40
P. 41
P. 42
P. 43
P. 44
P. 45
P. 46
P. 47
P. 48
P. 49
P. 50


See other catalogues for The MathWorks

Text version of the page
1 Matrices and Arrays
Empty Matrices
If you construct a matrix using empty matrix elements, the empty matrices are ignored in the resulting matrix:
A = [5.36; 7.01; []; 9.44] A =
5.3600 7.0100 9.4400
Concatenation Examples
Here are some examples of data type conversion during matrix construction.
Combining Single and Double Types. Combining single values with double values yields a single matrix. Note that 5.73*10A300 is too big to be stored as a single, thus the conversion from double to single sets it to infinity. (The class function used in this example returns the data type for the input value):
x = [single(4.5) single(-2.8) pi 5.73*10A300] x =
4.5000 -2.8000 3.1416 Inf
class(x) % Display the data type of x
ans = single
Combining Integer and Double Types. Combining integer values with double values yields an integer matrix. Note that the fractional part ofpi is rounded to the nearest integer. (The int8 function used in this example converts its numeric argument to an 8-bit integer):
x = [int8(21) int8(-22) int8(23) pi 45/6] x=
21 -22 23 3 7
1-16

pageCatalog pdf di En 2012-06-22-01