Documentation

This is machine translation

Translated by Microsoft
Mouse over text to see original. Click the button below to return to the English verison of the page.

我们为许可用户提供了部分翻译好的中文文档。您只需登录便可查阅这些文档

Control Flow

Conditional statements, loops, branching

MATLAB Language Syntax

if, elseif, else Execute statements if condition is true
for for loop to repeat specified number of times
parfor Parallel for loop
switch, case, otherwise Execute one of several groups of statements
try, catch Execute statements and catch resulting errors
while while loop to repeat when condition is true
break Terminate execution of for or while loop
continue Pass control to next iteration of for or while loop
end Terminate block of code, or indicate last array index
pause Stop MATLAB execution temporarily
return Return control to invoking function

Topics

Conditional Statements

To determine which block of code to execute at run time, use if or switch conditional statements.

Loop Control Statements

To repeatedly execute a block of code, use for and while loops.

Was this topic helpful?