MATLAB POLYSPACE RELEASE NOTES Manual de usuario Pagina 142

  • Descarga
  • Añadir a mis manuales
  • Imprimir
  • Pagina
    / 240
  • Tabla de contenidos
  • MARCADORES
  • Valorado. / 5. Basado en revisión del cliente
Vista de pagina 141
4 Programming
elseif A < B
'less'
elseif A == B
'equal'
else
error('Unexpected situatio n')
end
Several functions are helpful for reducing the results of matrix comparisons
to scalar cond itions for use with
if, including
isequal
isempty
all
any
switch and case
The switch statement executes groups of statements based on the value of
a variable or expression. The keywords
case and otherwise delineate the
groups. Only the first m atching case is executed. There must always be an
end to ma tch the switch.
The logic of the magic squares algorithm can also be described by
switch (rem(n,4)==0) + (rem(n,2)==0)
case 0
M = odd_magic(n)
case 1
M = single_even_magic( n)
case 2
M = double_even_magic( n)
otherwise
error('This is impossible')
end
Note Unlike the C language switch statement, MATLAB sw itch does not
fall through. If the first
case statem ent is true, the other case statements do
not e xecute. So,
break statements are n ot require d.
4-4
Vista de pagina 141
1 2 ... 137 138 139 140 141 142 143 144 145 146 147 ... 239 240

Comentarios a estos manuales

Sin comentarios