MATLAB FINANCIAL DERIVATIVES TOOLBOX Manual de usuario Pagina 29

  • Descarga
  • Añadir a mis manuales
  • Imprimir
  • Pagina
    / 119
  • Tabla de contenidos
  • MARCADORES
  • Valorado. / 5. Basado en revisión del cliente
Vista de pagina 28
28
parts of vectors (afterwards, with matrices, the colon can be used to view a
certain part of a matrix). For instance, the following commands produce
three different row vectors:
Matlab’s command:
>> v1=1:8, v2=-4:2:2, v3=[0.1:0.2:0.6]
Matlab’s response:
v1 =
1 2 3 4 5 6 7 8
v2 =
-4 -2 0 2
v3 =
0.1 0.3 0.5
The careful viewer should have notice that the vector creation via the use of
the colon notation has the form: starting_value:step:finishing_value. The
starting_value consists the first value/element of the vector, the
finishing_value is the last value/element of the vector and all other elements
differ by a value equal to step. Also, when the interval between
finishing_value and starting_value is not divisible by the step, the last value
of the vector is not the finishing_value (i.e. in
v
v
3
3 the last element is 0.5 and
not 0.6). The colon notation is also used to view or extract parts of a vector.
See the examples to get an idea.
Matlab’s command:
>> v4=v1(2:4)
Matlab’s response:
V4 =
2 3 4
Comments:
Extracting the 2
th
, 3
rd
and 4
th
elements of
v
v
1
1.
Matlab’s command:
>> v1(2:3:8)
Matlab’s response:
ans =
2 5 8
Comments:
Extracting the 2
th
, 5
th
and 8
th
elements of
v
v
1
1.
Vista de pagina 28
1 2 ... 24 25 26 27 28 29 30 31 32 33 34 ... 118 119

Comentarios a estos manuales

Sin comentarios