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
Common form of the switch statement: The common form of the switch statement is as shown below:   switch switch_expression   case caseexp1    action1   case cas

Built-in function for Differentiation: The MATLAB has a built-in function, diff that returns the differences between consecutive elements in a vector. For illustration, >>

User-defined functions: Therefore, although many functions compute and return values, some do not. A few functions rather merely accomplish a task. Regardless of what type of

Histogram: The histogram is a particular type of bar chart which shows the frequency of occurrence of the values within a vector. The Histograms use what are known as bins to

Counting in a While Loop: Whenever it is not known ahead of the time how many values will be entered into the script, it is often essential to count the number of values which

Using Functions with the Vectors and Matrices: As MATLAB is written to work with the vectors and matrices, the whole vector or matrix can be passed as an argument to the funct

How do I write a product series running from i to n of x''s using a for loop?

Concatenation: The String concatenation means to join the strings altogether. Of course, as strings are merely vectors of the characters, the technique of concatenating vector

Illustration of Advanced file input and output: For illustration, to refer to the third number in the first element of the cell array: >> subjdata{1}(3) ans =

Built in recursive function in MATLAB: We have seen that the built-in function in MATLAB to compute factorials, termed as the factorial and we know how to implement the iterat