MATLAB FINANCIAL DERIVATIVES TOOLBOX Manual do Utilizador Página 31

  • Descarregar
  • Adicionar aos meus manuais
  • Imprimir
  • Página
    / 119
  • Índice
  • MARCADORES
  • Avaliado. / 5. Com base em avaliações de clientes
Vista de página 30
30
2.1.3 Transporting Vectors
To perform operation with column and row vectors of similar length, it is
first needed to transpose the vectors in order to make them either all row
vectors or column ones. The apostrophe symbol “ ' “ is used to convert a
column vector to a row one and vise versa. Remember that the length of the
vectors must match; otherwise, Matlab will return an error. Experiment with
the following examples to learn the use of transpose command.
Matlab’s command:
>> z1 = [2 -1 3], z2 = z1', z3 = z2'''
Matlab’s response:
z1 =
2 -1 3
z2 =
2
-1
3
z3 =
2 -1 3
Comments:
z
z
1
1 is a three element row vector.
z
z
2
2 is the transpose of
z
z
1
1.
z
z
3
3 is
similar with
z
z
1
1 since after transposing
z
z
2
2 three times is similar as
transposing once the
z
z
2
2.
Matlab’s command:
>> z1'+z2, z1+z2
Matlab’s response:
ans =
4
-2
6
??? Error using ==> +
Matrix dimensions must agree.
Comments:
z
z
1
1
'
'
+
+
z
z
2
2 operation involves the addition of two column vectors.
z
z
1
1
+
+
z
z
2
2 is an illegal operation since a row vector cannot be added
with a column vector.
Note that that Matlab can store empty vectors. This is done as follows:
Vista de página 30
1 2 ... 26 27 28 29 30 31 32 33 34 35 36 ... 118 119

Comentários a estes Manuais

Sem comentários