Geoscience Reference
In-Depth Information
c = 0 : 10
which creates a vector, or a one-dimensional array with a single row,
containing all integers from 0 to 10. h e resultant MATLAB response is
c =
0 1 2 3 4 5 6 7 8 9 10
Note that this statement creates 11 elements, i.e., the integers from 1 to 10
and the zero. A common error when indexing arrays is to ignore the zero
and therefore expect 10 elements instead of 11 in our example. We can check
this from the output of whos .
Name Size Bytes Class Attributes
A 4x4 128 double
ans 1x1 8 double
b 1x1 8 double
c 1x11 88 double
h e above command creates only integers, i.e., the interval between the
array elements is one unit. However, an arbitrary interval can be dei ned, for
example 0.5 units. h is is later used to create evenly-spaced time vectors for
time series analysis. Typing
c = 1 : 0.5 : 10
results in the display
c =
Columns 1 through 6
1.0000 1.5000 2.0000 2.5000 3.0000 3.5000
Columns 7 through 12
4.0000 4.5000 5.0000 5.5000 6.0000 6.5000
Columns 13 through 18
7.0000 7.5000 8.0000 8.5000 9.0000 9.5000
Column 19
10.0000
which autowraps the lines that are longer than the width of the Command
Window. h e display of the values of a variable can be interrupted by pressing
Ctrl+C ( Control+C ) on the keyboard. h is interruption af ects only the
output in the Command Window, whereas the actual command is processed
before displaying the result.
MATLAB provides standard arithmetic operators for addition, + , and
subtraction, - . h e asterisk, * , denotes matrix multiplication involving inner
products between rows and columns. For instance, we multiply the matrix A
with a new matrix B
Search WWH ::




Custom Search