# How To Apply SWITCH Command in MATLAB

In previous post on matlab tutorial, we discussed about, How to replace below threshold element of Matrix with zero in MATLAB with its matlab program. Now in

**Post-15 of Module-01**, we will discuss about, how to apply switch command in matlab.
To understand this problem, we are converting number into words. If number is between

**o to 9**then it will display it in words otherwise it will display a message showing**number is out of limit**. MATLAB program for this problem has been shown in figure-1.
Figure.1 - MATLAB Program to apply switch command.

In this matlab program two important things are there i.e.

**switch**and its**case**. User can enter any number which will be placed after switch command and It will be compared with number number written after case. If switch number is equal to case number then a command written in respective**'case'**will be executed. Else it will execute command written in**'otherwise'**. Command window output of this matlab program has been shown in figure-2.
When number

**'0'**is typed after function, matlab program is displaying it in words i.e.**Zero**. If number**'3'**is typed after function, matlab program is displaying it in words i.e.**Three**. If number**'7'**is typed after function, matlab program is displaying it in words i.e.**Seven**and If number**'17'**is typed after function, matlab program is displaying a message i.e.**Number Limit Exceed**.
This is concluded that we can execute any matlab code by using switch function for numbers. Now next question which comes into our mind is that can we use switch function for words. This question we will be discuss in next post.

Video Tutorial : How To Apply Switch Command in MATLAB.

Brought to you By INFO4EEE (Website, Channel, and Classes).

## Post a Comment