Common form of the switch statement, MATLAB in Mathematics

Common form of the switch statement:

The common form of the switch statement is as shown below:

 

switch switch_expression

  case caseexp1

   action1

  case caseexp2

   action2

  case caseexp3

   action3

  % etc: there can be many of these

  otherwise

   actionn

end

 

The switch statement begins with the reserved word switch, and ends with reserved word end. switch_expression is compared, in series, to the case expressions (caseexp1, caseexp2, etc.). If the value of the switch_expression matches the caseexp1, for illustration, then action1 is executed and the switch statement ends. If the value matches caseexp3, then the action3 is executed, and in common if the value matches caseexpi, where i can be any of the integer from 1 to n, then actioni is executed. When the value of the switch_expression does not match any of the case expressions, the action is taken after the word or else is executed.

Posted Date: 10/19/2012 3:22:45 AM | Location : United States







Related Discussions:- Common form of the switch statement, Assignment Help, Ask Question on Common form of the switch statement, Get Answer, Expert's Help, Common form of the switch statement Discussions

Write discussion on Common form of the switch statement
Your posts are moderated
Related Questions
Labels and Prompts: The script loads all the numbers from file into a row vector. It then splits the vector; it stores the initial element that is the experiment number in a v

Strings as matrix: The matrix can be generated, that consists of strings in each row. Therefore, essentially it is created as a column vector of strings, but the final result

Matrix of Plots: The other function which is very useful with any type of plot is subplot that creates a matrix of plots in the present Figure Window. The three arguments are

Differentiation: The derivative of a function y = f(x) can be written as follows or f  '(x) and is defined as the rate of change of the dependent variable y with respe

Example of Symbolic Expression When there is more than one variable, the MATLAB selects which to solve for. In the illustration below, the equation ax 2 + bx = 0 is solved. Th

Empty Vectors: An empty vector or in another words, a vector which stores no values, can be generated using the empty square brackets: >> evec = [] evec = [] >> lengt

Built-in functions for Complex numbers:   We know that in MATLAB both i and j are built-in functions which return √-1 (therefore, they can be thought of as built-in constants).

Give the formula for a rational function that has a hole at x=7 & vertical asmptote at x=-3/2

Types of User-defined Functions: We know how to write a user-defined function, stored in an M-file, which computes and returns one value. This is merely one type of the functi

Writing to Files: There are many lower level functions which can write to files. We will focus on the fprintf function that can be used to write a file and also to append to a