MATLAB FINANCIAL DERIVATIVES TOOLBOX Instrukcja Użytkownika Strona 80

  • Pobierz
  • Dodaj do moich podręczników
  • Drukuj
  • Strona
    / 119
  • Spis treści
  • BOOKMARKI
  • Oceniono. / 5. Na podstawie oceny klientów
Przeglądanie stron 79
79
error); you have to return to the Editor to debug the error, re-save the
function and try to run it again. If you debug your function or add something,
then you have to re-save the file in order to take place the changes (note that
if unsaved changes are made in a function file, an asterisk (*) appears next
to the function name in the Editor’s title bar (so in Figure 12, the functions
has not been saved); ii) although the input argument of the function is a
matrix named
X
X and the output is a vector named
V
V, when you call this
function from a script or from the command window, you can give any names
you like. For example in the command window enter:
“[DiagElements]=DiagExtract(magic(4))”
to see the result; iii) After the function is executed, none of the variables that
were used are saved in the workspace; iv) If after each command line you do
not place the semi-colon “;” then when the function is executed, you can
observe in the command window the result of these command lines (this is
useful to be done when you try to debug a function); v) observe on Figure 12
that on the bottom of the Editor/Debugger there is a predefined caption area
that indicates that the current m-file is a function with the name
D
D
i
i
a
a
g
g
E
E
x
x
t
t
r
r
a
a
c
c
t
t.
5.1.1 Basic Parts of a Function
A function is composed from the following parts (most of this section is
taken/copied from [2])
5.1.1.1 Function Definition Line
The
f
f
u
u
n
n
c
c
t
t
i
i
o
o
n
n definition line informs Matlab that the m-file contains a
f
f
u
u
n
n
c
c
t
t
i
i
o
o
n
n, and specifies the argument calling sequence of the function. For
example, the
f
f
u
u
n
n
c
c
t
t
i
i
o
o
n
n definition line for the
a
a
v
v
e
e
r
r
a
a
g
g
e
e function (that computes
the average of a vector) could be:
Przeglądanie stron 79
1 2 ... 75 76 77 78 79 80 81 82 83 84 85 ... 118 119

Komentarze do niniejszej Instrukcji

Brak uwag