MATLAB FINANCIAL DERIVATIVES TOOLBOX Bedienungsanleitung Seite 74

  • Herunterladen
  • Zu meinen Handbüchern hinzufügen
  • Drucken
  • Seite
    / 119
  • Inhaltsverzeichnis
  • LESEZEICHEN
  • Bewertet. / 5. Basierend auf Kundenbewertungen
Seitenansicht 73
73
Although is possible to run these examples via the command window, it is
better to use the Matlab Editor/Debugger to write a script instead. Real
examples with the conditional statements as well as with the loops are
postponed until the introduction of scripts in section 5.
4.2.2 The
s
s
w
w
i
i
t
t
c
c
h
h Statement
The
s
s
w
w
i
i
t
t
c
c
h
h statement executes groups of statements based on the value of a
variable or expression. The keywords
c
c
a
a
s
s
e
e
and
o
o
t
t
h
h
e
e
r
r
w
w
i
i
s
s
e
e delineate the
groups. Only the first matching case is executed. There must always be an
e
e
n
n
d
d to match the
s
s
w
w
i
i
t
t
c
c
h
h. [2]. The expression following the
c
c
a
a
s
s
e
e
should be
either a scalar or a string. The syntax of this conditional expression is
tabulated in Table 8.
Syntax Example
switch expression
case
choice #1
segment of executable programming code
case choice #2
segment of executable programming code
otherwise
segment of executable programming code
end
dice=3;
switch (dice)
case 1
disp('One')
case 2
disp('Two')
case 3
disp('Three')
case 4
disp('Five')
case 5
disp('Five')
otherwise
disp('Six')
end
Table 8: The
s
s
w
w
i
i
t
t
c
c
h
h statement syntax and example.
4.3. Loop Expressions
As mentioned before, loop statements are useful when a segment of
executable programming code is needed to be executed either a specific
number of times, than or as long as an expression is TRUE. The
f
f
o
o
r
r and
w
w
h
h
i
i
l
l
e
e loop statements are needed commands when writing efficient
programming code.
Seitenansicht 73
1 2 ... 69 70 71 72 73 74 75 76 77 78 79 ... 118 119

Kommentare zu diesen Handbüchern

Keine Kommentare