SlideShare a Scribd company logo
4
Most read
8
Most read
13
Most read
MATLAB
Looping
Control Statements
CS-5
By: Prof. Ganesh Ingle
Course Main Topic/Chapters
Introduction
Overview of Loop statement
For loop
While loop
Nested loop
While loop vs for loop
Introduction
A loop is used for executing a block of
statements repeatedly until a particular
condition is satisfied.
For example, when you are displaying number from
1 to 100 you may want set the value of a variable
to 1 and display it 100 times, increasing its value
by 1 on each loop iteration.
Introduction
A loop is used for executing a block of
statements repeatedly until a particular
condition is satisfied.
For example, when you are displaying number from
1 to 100 you may want set the value of a variable
to 1 and display it 100 times, increasing its value
by 1 on each loop iteration.
Basic Structure of a Loop Statement
A loop is used for
executing a block
of statements
repeatedly until a
particular
condition is
satisfied.
Types of Loops
Loops are of 2 types:
Entry-controlled and exit-controlled.
'C' programming provides us
1) while
2) for loop
3) Nested Loop
For and while loop are also called as entry-
controlled loops.
Questions to be Asked ??
In the exam questions can be asked are
1) What do you mean by loop control
statement explain in detail.
Answer: Must include: syntax, example,
flowchart, entry control and exit
control loop difference
2) Write a program ………..
for Loop Syntax
for Loop Example
for index = values, statements, end executes a group of statements in a
loop for a specified number of times. values has one of the following
forms:
initVal:endVal — Increment the index variable from initVal to endVal by
1, and repeat execution of statements until index is greater than
endVal.
initVal:step:endVal — Increment index by the value step on each
iteration, or decrements index when step is negative.
valArray — Create a column vector, index, from subsequent columns of
array valArray on each iteration. For example, on the first iteration,
index = valArray(:,1). The loop executes a maximum of n times, where
n is the number of columns of valArray, given by numel(valArray(1,:)).
The input valArray can be of any MATLAB data type, including a
character vector, cell array, or struct.
while Loop Syntax
while vs for Loop
Programming Exercise
Lets start with programming!!!
Programming Exercise
Q.1 WAP to display Fibonacci series up to n terms
Programming Exercise
Q.2 WAP to display Fibonacci series up to n terms (Different logic)
Programming Exercise
Q.3 WAP to Check entered number is magic number
(Condensing a number to single digit, if the yielded single digit is one(1) then it is termed as magic number)
Programming Exercise
Q.4 WAP to Check entered number is Palindrome number
Number= Reverse number
Programming Exercise
Q.5 WAP to Check entered number is perfect number
Programming Exercise
Q.6 WAP to Check entered number is prime number
Programming Exercise
Q.7 WAP to Check entered number is Special number,
Digits factorial addition = number , 145=1!+4!+5!=145
Programming Exercise
Q.8 WAP to Check entered number is Armstrong number,
Digits cube addition = number , 153
Programming Exercise
Q. 9 Display pattern
THANK YOU

More Related Content

PPTX
RPA ppt.pptx
PDF
RPA Automation Tutorial | RPA Training | RPA Tutorial For Beginners | Edureka
PDF
Orchestrator - Practical Approach to host UiPath Orchestrator
PDF
interaction Norman form example 7 stage example
PPTX
UiPath Test Automation Webinar Recap
PDF
Robotics: Modelling, Planning and Control
PPTX
How to design RPA performance metrics
PDF
Boost Customer Experience with UiPath & AWS Contact Center Automation
RPA ppt.pptx
RPA Automation Tutorial | RPA Training | RPA Tutorial For Beginners | Edureka
Orchestrator - Practical Approach to host UiPath Orchestrator
interaction Norman form example 7 stage example
UiPath Test Automation Webinar Recap
Robotics: Modelling, Planning and Control
How to design RPA performance metrics
Boost Customer Experience with UiPath & AWS Contact Center Automation

What's hot (20)

PPTX
Evaluation techniques in HCI
PPTX
UI/UX Fundamentals
PDF
UiPath Email Automation | UiPath Tutorial | RPA Training Using UiPath | Edureka
PDF
2022.06 Community Update.pdf
PDF
Robotics or Robot Technology
PPTX
Artificial intelligence in software engineering ppt.
PDF
Robotics for Path Planning
PPTX
Differential kinematics robotic
PDF
Introduction to Human Computer Interaction
PDF
Robotic Process Automation (RPA)
PDF
UX design.pdf
PPTX
Ui path| RPA
PPTX
UiPath Meetup Service now + mainframe and legacy final
PPT
Intro to Robotics 1
PPTX
Robotic process automation
PPTX
UiPath Community Event - UiPath Action Center and UiPath Apps - human in the ...
PPTX
Power Automate - RPA, AI and digital process automation for all.pptx
PPTX
UI/UX presentation by Roshan Karunarathna
PDF
Intro Artificial Intelligence
Evaluation techniques in HCI
UI/UX Fundamentals
UiPath Email Automation | UiPath Tutorial | RPA Training Using UiPath | Edureka
2022.06 Community Update.pdf
Robotics or Robot Technology
Artificial intelligence in software engineering ppt.
Robotics for Path Planning
Differential kinematics robotic
Introduction to Human Computer Interaction
Robotic Process Automation (RPA)
UX design.pdf
Ui path| RPA
UiPath Meetup Service now + mainframe and legacy final
Intro to Robotics 1
Robotic process automation
UiPath Community Event - UiPath Action Center and UiPath Apps - human in the ...
Power Automate - RPA, AI and digital process automation for all.pptx
UI/UX presentation by Roshan Karunarathna
Intro Artificial Intelligence
Ad

Similar to Programming with matlab session 5 looping (20)

PDF
Looping in c language
PPTX
Week 4.pptx computational thinking and programming
PPT
Iteration
PDF
Loops_in_Rv1.2b
PPTX
Comp ppt (1)
PPTX
NUMERICAL METHODS WITH MATLAB PROGRAMMING
PPT
Programming loop
PDF
Ma3696 lecture 4
PPT
Loops Do While Arduino Programming Robotics
PDF
Python_Module_2.pdf
PPTX
Loops c++
PPT
Conditional Loops Python
PPTX
Loops in R
PDF
2 Python Basics II meeting 2 tunghai university pdf
PPTX
Module_2_1_Building Python Programs_Final.pptx
PDF
Notes2
PPTX
C language (Part 2)
PDF
Chapter 12 Computer Science ( ICS 12).pdf
PDF
Java Script Basics presentation of program
Looping in c language
Week 4.pptx computational thinking and programming
Iteration
Loops_in_Rv1.2b
Comp ppt (1)
NUMERICAL METHODS WITH MATLAB PROGRAMMING
Programming loop
Ma3696 lecture 4
Loops Do While Arduino Programming Robotics
Python_Module_2.pdf
Loops c++
Conditional Loops Python
Loops in R
2 Python Basics II meeting 2 tunghai university pdf
Module_2_1_Building Python Programs_Final.pptx
Notes2
C language (Part 2)
Chapter 12 Computer Science ( ICS 12).pdf
Java Script Basics presentation of program
Ad

More from Infinity Tech Solutions (20)

PDF
Database management system session 6
PDF
Database management system session 5
PDF
Database Management System-session 3-4-5
PDF
Database Management System-session1-2
PDF
Main topic 3 problem solving and office automation
PDF
Introduction to c programming
PDF
PDF
Bds session 13 14
PDF
Computer memory, Types of programming languages
PDF
Basic hardware familiarization
PDF
User defined functions in matlab
PDF
Programming with matlab session 6
PDF
Programming with matlab session 3 notes
PPTX
AI/ML/DL/BCT A Revolution in Maritime Sector
PDF
BIG DATA Session 7 8
PDF
BIG DATA Session 6
PDF
Database management system session 6
Database management system session 5
Database Management System-session 3-4-5
Database Management System-session1-2
Main topic 3 problem solving and office automation
Introduction to c programming
Bds session 13 14
Computer memory, Types of programming languages
Basic hardware familiarization
User defined functions in matlab
Programming with matlab session 6
Programming with matlab session 3 notes
AI/ML/DL/BCT A Revolution in Maritime Sector
BIG DATA Session 7 8
BIG DATA Session 6

Recently uploaded (20)

PPTX
MET 305 MODULE 1 KTU 2019 SCHEME 25.pptx
PDF
Operating System & Kernel Study Guide-1 - converted.pdf
PPTX
Fluid Mechanics, Module 3: Basics of Fluid Mechanics
PDF
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
PDF
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
PPTX
Simulation of electric circuit laws using tinkercad.pptx
PDF
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
PPTX
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
PPTX
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
PDF
오픈소스 LLM, vLLM으로 Production까지 (Instruct.KR Summer Meetup, 2025)
PPTX
Sustainable Sites - Green Building Construction
PPTX
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
PDF
Structs to JSON How Go Powers REST APIs.pdf
PPTX
The-Looming-Shadow-How-AI-Poses-Dangers-to-Humanity.pptx
DOCX
573137875-Attendance-Management-System-original
PDF
Embodied AI: Ushering in the Next Era of Intelligent Systems
PDF
ETO & MEO Certificate of Competency Questions and Answers
PPTX
Unit 5 BSP.pptxytrrftyyydfyujfttyczcgvcd
PPTX
MCN 401 KTU-2019-PPE KITS-MODULE 2.pptx
PPTX
Foundation to blockchain - A guide to Blockchain Tech
MET 305 MODULE 1 KTU 2019 SCHEME 25.pptx
Operating System & Kernel Study Guide-1 - converted.pdf
Fluid Mechanics, Module 3: Basics of Fluid Mechanics
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
Simulation of electric circuit laws using tinkercad.pptx
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
오픈소스 LLM, vLLM으로 Production까지 (Instruct.KR Summer Meetup, 2025)
Sustainable Sites - Green Building Construction
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
Structs to JSON How Go Powers REST APIs.pdf
The-Looming-Shadow-How-AI-Poses-Dangers-to-Humanity.pptx
573137875-Attendance-Management-System-original
Embodied AI: Ushering in the Next Era of Intelligent Systems
ETO & MEO Certificate of Competency Questions and Answers
Unit 5 BSP.pptxytrrftyyydfyujfttyczcgvcd
MCN 401 KTU-2019-PPE KITS-MODULE 2.pptx
Foundation to blockchain - A guide to Blockchain Tech

Programming with matlab session 5 looping

  • 2. Course Main Topic/Chapters Introduction Overview of Loop statement For loop While loop Nested loop While loop vs for loop
  • 3. Introduction A loop is used for executing a block of statements repeatedly until a particular condition is satisfied. For example, when you are displaying number from 1 to 100 you may want set the value of a variable to 1 and display it 100 times, increasing its value by 1 on each loop iteration.
  • 4. Introduction A loop is used for executing a block of statements repeatedly until a particular condition is satisfied. For example, when you are displaying number from 1 to 100 you may want set the value of a variable to 1 and display it 100 times, increasing its value by 1 on each loop iteration.
  • 5. Basic Structure of a Loop Statement A loop is used for executing a block of statements repeatedly until a particular condition is satisfied.
  • 6. Types of Loops Loops are of 2 types: Entry-controlled and exit-controlled. 'C' programming provides us 1) while 2) for loop 3) Nested Loop For and while loop are also called as entry- controlled loops.
  • 7. Questions to be Asked ?? In the exam questions can be asked are 1) What do you mean by loop control statement explain in detail. Answer: Must include: syntax, example, flowchart, entry control and exit control loop difference 2) Write a program ………..
  • 9. for Loop Example for index = values, statements, end executes a group of statements in a loop for a specified number of times. values has one of the following forms: initVal:endVal — Increment the index variable from initVal to endVal by 1, and repeat execution of statements until index is greater than endVal. initVal:step:endVal — Increment index by the value step on each iteration, or decrements index when step is negative. valArray — Create a column vector, index, from subsequent columns of array valArray on each iteration. For example, on the first iteration, index = valArray(:,1). The loop executes a maximum of n times, where n is the number of columns of valArray, given by numel(valArray(1,:)). The input valArray can be of any MATLAB data type, including a character vector, cell array, or struct.
  • 11. while vs for Loop
  • 12. Programming Exercise Lets start with programming!!!
  • 13. Programming Exercise Q.1 WAP to display Fibonacci series up to n terms
  • 14. Programming Exercise Q.2 WAP to display Fibonacci series up to n terms (Different logic)
  • 15. Programming Exercise Q.3 WAP to Check entered number is magic number (Condensing a number to single digit, if the yielded single digit is one(1) then it is termed as magic number)
  • 16. Programming Exercise Q.4 WAP to Check entered number is Palindrome number Number= Reverse number
  • 17. Programming Exercise Q.5 WAP to Check entered number is perfect number
  • 18. Programming Exercise Q.6 WAP to Check entered number is prime number
  • 19. Programming Exercise Q.7 WAP to Check entered number is Special number, Digits factorial addition = number , 145=1!+4!+5!=145
  • 20. Programming Exercise Q.8 WAP to Check entered number is Armstrong number, Digits cube addition = number , 153
  • 21. Programming Exercise Q. 9 Display pattern