Main Content

Loops and Conditional Statements

Control flow and branching using keywords, such as if, for, and while

Within any program, you can define sections of code that either repeat in a loop or conditionally execute. Loops use a for or while keyword, and conditional statements use if or switch. Additional keywords provide finer control over the program flow.

Syntaxe du langage MATLAB

if, elseif, elseExécuter les instructions si la condition est vraie
switch, case, otherwiseExécuter un ou plusieurs groupes d’instructions
forboucle for se répétant un nombre de fois spécifié
whileBoucle while permet de répéter tant que la condition est vraie
try, catchExecute statements and catch resulting errors
breakMettre fin à l’exécution d’une boucle for ou while
returnReturn control to invoking script or function
continuePass control to next iteration of for or while loop
pauseStop MATLAB execution temporarily
parforParallel for-loop
endTerminate block of code or indicate last array index

Rubriques