MATLAB FINANCIAL DERIVATIVES TOOLBOX Manual de usuario Pagina 76

  • Descarga
  • Añadir a mis manuales
  • Imprimir
  • Pagina
    / 119
  • Tabla de contenidos
  • MARCADORES
  • Valorado. / 5. Basado en revisión del cliente
Vista de pagina 75
75
4.3.3. Nested Conditional and Loop Expressions
All conditional and loop statements can be combined in any way that is
desirable. If for example a loop expression includes an
i
i
f
f statement that
nests a
s
s
w
w
i
i
t
t
c
c
h
h statement and so on, then, in programming terminology, it is
termed that we have nested statements. As long as the statements are
nested in a logical and a non redundant manner, the user will get correct
answers. View the following example that is exhibited in Table 11 and nests
various statements (figure out their use).
An example of syntax of nested conditional and loop statements
clear; flag=1; x=2*pi; temp=pi;
while x<=4*pi
figure; hold on;
X=temp:pi/10:x;
for j=1:4
subplot(2,2,j); plot(X,sin(j*X)./X, 'b:', 'LineWidth', 3);
switch (j)
case 1
title('Plot of y=sin(x)/x');
case 2
title(' Plot of y=sin(2x)/x');
case 3
title(' Plot of y=sin(3x)/x');
otherwise
title(' Plot of y=sin(4x)/x');
end
xlabel('x'); ylabel('y');
end
temp=x; x=x+pi;
end
Table 11: Nested conditional and loop statements.
4.3.4. Additional Control Flow Statements
Matlab has additional control flow statements that can be used to write an
executable script or function. These are more specialized statements that are
listed in Table 12. You can learn more details via the online help.
Vista de pagina 75
1 2 ... 71 72 73 74 75 76 77 78 79 80 81 ... 118 119

Comentarios a estos manuales

Sin comentarios