Calq commands and keywords

Keyword

case

Definition

This keyword is used inside a switch block. We compare the expression following the switch keyword, and try to match it to one of the "case" values. If none of them match, we will select the "otherwise" block, if it exists. There should be at least one "case" within a switch block, and there can be many of them. The "otherwise" part may not be specified. If so, there is only one "otherwise" per switch command.

Example

  a = 2;
  switch (a)
    case 1
      disp('one');
    case 2
      disp('two');
    otherwise
      disp('not one or two');
  end

  two

See also

switch. if. otherwise.


What is Calq?
Latest version of Calq
Digital Wave Systems Lab homepage