# How To Apply IF ELSE in MATLAB

In previous matlab tutorial, we have discussed about How to apply switch command for word in MATLAB with its matlab program. Now in

**Post-17 of Module-01**, we will discuss about how to apply**IF ELSE**in matlab.
To understand this problem, we will create a matlab program to display the division according to marks. MATLAB program for this problem has been shown in

**figure-1**.
Figure.1 - MATLAB Program to apply IF ELSE.

First of all user is asked to enter his/her percentage of marks by the command

**'input'**which store the percentage in**percentage**variable. After that it is compared with the help of**IF ELSE**condition. If percentage of marks is less than**33 %**then it display a message written in**line-6**i.e.**'You are FAIL'**. If percentage of marks is greater or equal to**33 %**but less than**45 %**then it display a message written in**line-8**i.e.**'You are passed with THIRD Division'**. If percentage of marks is greater or equal to**45 %**but less than**60 %**then it display a message written in**line-10**i.e.**'You are passed with SECOND Division'**. If percentage of marks is greater or equal to**60 %**but less than**75 %**then it display a message written in**line-12**i.e.**'You are passed with FIRST Division'**. If percentage of marks is greater or equal to**75 %**then it display a message written in**line-14**i.e.**'You are passed with HONOURS'**.
Figure.2 - Command Window output of matlab program for IF ELSE.

This program can be run by typing its name on command window i.e.

**'mod0117'**. After this a message is displayed on command window which asked the user to enter his percentage of marks. When user enter his percentage of marks then it display the division of the user. The command window output for this has been shown in**figure-2.****Video Tutorial :**How To Apply If Else in MATLAB By INFO4EEE

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

[…] previous matlab tutorial post, we have discussed about How to apply IF ELSE in MATLAB with its matlab program. Now in Post-18 of Module-01, we will discuss about how to store multiple […]

ReplyDelete[…] Read Post-17 of Module-I: How To Apply IF ELSE in MATLAB. […]

ReplyDelete