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
Matlab Functions
PPT
Matlab Basic Tutorial
PDF
Matlab introduction lecture 1
PDF
MATLAB Basics-Part1
PDF
MATLAB Programming
PPTX
For Loops and Nesting in Python
PPTX
Matlab Script - Loop Control
PPT
Hebbian Learning
Matlab Functions
Matlab Basic Tutorial
Matlab introduction lecture 1
MATLAB Basics-Part1
MATLAB Programming
For Loops and Nesting in Python
Matlab Script - Loop Control
Hebbian Learning

What's hot (20)

PDF
Matlab intro
PPT
Ll(1) Parser in Compilers
PPT
The Evolution of Java
PPT
Python List.ppt
PDF
Python GUI
PPT
Collective Communications in MPI
PPSX
Introduction to MATLAB
PDF
Introduction to matlab
PPTX
Python-DataAbstarction.pptx
PPSX
Lasso and ridge regression
PDF
Introduction to Matlab
PDF
10. funtions and closures IN SWIFT PROGRAMMING
PDF
Python libraries
PDF
Types of pointer in C
PDF
Discrete Mathematics S. Lipschutz, M. Lipson And V. H. Patil
PDF
Python Modules
PDF
5. Linear Algebra for Machine Learning: Singular Value Decomposition and Prin...
PPTX
Looping statement in vb.net
PPTX
Matlab ppt
PPTX
Python Lambda Function
Matlab intro
Ll(1) Parser in Compilers
The Evolution of Java
Python List.ppt
Python GUI
Collective Communications in MPI
Introduction to MATLAB
Introduction to matlab
Python-DataAbstarction.pptx
Lasso and ridge regression
Introduction to Matlab
10. funtions and closures IN SWIFT PROGRAMMING
Python libraries
Types of pointer in C
Discrete Mathematics S. Lipschutz, M. Lipson And V. H. Patil
Python Modules
5. Linear Algebra for Machine Learning: Singular Value Decomposition and Prin...
Looping statement in vb.net
Matlab ppt
Python Lambda Function
Ad

Similar to Programming with matlab session 5 looping (20)

PPTX
NUMERICAL METHODS WITH MATLAB PROGRAMMING
PPT
Loop Statements [5] M
PDF
Looping in c language
PDF
Repetition, Basic loop structures, Loop programming techniques
PPTX
A Complete Guide on While Loop in MATLAB
PDF
Matlab tutorial 3
PDF
Matlab practical ---3.pdf
PDF
04 a ch03_programacion
DOC
Slide07 repetitions
PPT
Conditional Loops Python
PPTX
Csci101 lect06 advanced_looping
PPT
PPTX
Iterations FOR LOOP AND WHILE LOOP .pptx
PPT
Mesics lecture 7 iteration and repetitive executions
PPT
Fundamentals of Programming Chapter 7
DOCX
CMIS 102 Hands-On Lab Week 4OverviewThis hands-on lab all.docx
PPTX
Chapter 3 - Programming in Matlab. aaaapptx
PDF
Slide 6_Control Structures.pdf
PDF
4-Loops computer programming in c btech.pdf
NUMERICAL METHODS WITH MATLAB PROGRAMMING
Loop Statements [5] M
Looping in c language
Repetition, Basic loop structures, Loop programming techniques
A Complete Guide on While Loop in MATLAB
Matlab tutorial 3
Matlab practical ---3.pdf
04 a ch03_programacion
Slide07 repetitions
Conditional Loops Python
Csci101 lect06 advanced_looping
Iterations FOR LOOP AND WHILE LOOP .pptx
Mesics lecture 7 iteration and repetitive executions
Fundamentals of Programming Chapter 7
CMIS 102 Hands-On Lab Week 4OverviewThis hands-on lab all.docx
Chapter 3 - Programming in Matlab. aaaapptx
Slide 6_Control Structures.pdf
4-Loops computer programming in c btech.pdf
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
UNIT-1 - COAL BASED THERMAL POWER PLANTS
PPTX
Sustainable Sites - Green Building Construction
PDF
PPT on Performance Review to get promotions
PPT
Project quality management in manufacturing
PPTX
Internet of Things (IOT) - A guide to understanding
PPTX
bas. eng. economics group 4 presentation 1.pptx
PPTX
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
PPTX
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
PPTX
MCN 401 KTU-2019-PPE KITS-MODULE 2.pptx
PPTX
CYBER-CRIMES AND SECURITY A guide to understanding
PDF
Embodied AI: Ushering in the Next Era of Intelligent Systems
PDF
Arduino robotics embedded978-1-4302-3184-4.pdf
DOCX
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
PPTX
Lecture Notes Electrical Wiring System Components
PDF
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
PDF
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
PPTX
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
PPTX
UNIT 4 Total Quality Management .pptx
PPTX
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
PDF
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
UNIT-1 - COAL BASED THERMAL POWER PLANTS
Sustainable Sites - Green Building Construction
PPT on Performance Review to get promotions
Project quality management in manufacturing
Internet of Things (IOT) - A guide to understanding
bas. eng. economics group 4 presentation 1.pptx
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
MCN 401 KTU-2019-PPE KITS-MODULE 2.pptx
CYBER-CRIMES AND SECURITY A guide to understanding
Embodied AI: Ushering in the Next Era of Intelligent Systems
Arduino robotics embedded978-1-4302-3184-4.pdf
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
Lecture Notes Electrical Wiring System Components
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
UNIT 4 Total Quality Management .pptx
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...

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