enow.com Web Search

Search results

  1. Results from the WOW.Com Content Network
  2. for - for loop to repeat specified number of times - MATLAB -...

    www.mathworks.com/help/matlab/ref/for.html

    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 ...

  3. Loop Control Statements - MATLAB & Simulink - MathWorks

    www.mathworks.com/help/matlab/matlab_prog/loop-control-statements.html

    With loop control statements, you can repeatedly execute a block of code. There are two types of loops: for statements loop a specific number of times, and keep track of each iteration with an incrementing index variable. For example, preallocate a 10-element vector, and calculate five values: x = ones(1,10); for n = 2:6. x(n) = 2 * x(n - 1); end.

  4. while - while loop to repeat when condition is true - MATLAB -...

    www.mathworks.com/help/matlab/ref/while.html

    Description. while expression, statements, end evaluates an expression, and repeats the execution of a group of statements in a loop while the expression is true. An expression is true when its result is nonempty and contains only nonzero elements (logical or real numeric). Otherwise, the expression is false. example.

  5. Loops and Conditional Statements - MATLAB & Simulink - MathWorks

    www.mathworks.com/help/matlab/control-flow.html

    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 ...

  6. colon - Vector creation, array subscripting, and for-loop...

    www.mathworks.com/help/matlab/ref/double.colon.html

    The colon is one of the most useful operators in MATLAB ®. It can create vectors, subscript arrays, and specify for iterations. x = j:k creates a unit-spaced vector x with elements [j,j+1,j+2,...,j+m] where m =. fix(k-j). If j and k are both integers, then this is simply [j,j+1,...,k]. example. x = j:i:k creates a regularly-spaced vector x ...

  7. if expression, statements, end evaluates an expression, and executes a group of statements when the expression is true. An expression is true when its result is nonempty and contains only nonzero elements (logical or real numeric). Otherwise, the expression is false. The elseif and else blocks are optional.

  8. continue - Pass control to next iteration of for or while loop -...

    www.mathworks.com/help/matlab/ref/continue.html

    Description. continue passes control to the next iteration of a for or while loop. It skips any remaining statements in the body of the loop for the current iteration. The program continues execution from the next iteration. continue applies only to the body of the loop where it is called. In nested loops, continue skips remaining statements ...

  9. break - Terminate execution of for or while loop - MATLAB -...

    www.mathworks.com/help/matlab/ref/break.html

    Description. break terminates the execution of a for or while loop. Statements in the loop after the break statement do not execute. In nested loops, break exits only from the loop in which it occurs. Control passes to the statement that follows the end of that loop. example.

  10. How do I create a for loop in MATLAB? - MathWorks

    www.mathworks.com/matlabcentral/answers/31156

    Open in MATLAB Online. A basic for loop in MATLAB is often used to assign to or access array elements iteratively. For example, let’s say you have a vector A, and you want to simply display each value one at a time: Theme. Copy. A = [3 6 9 4 1]; for i = 1:length (A) disp (A (i)) end.

  11. switch - Execute one of several groups of statements - MATLAB -...

    www.mathworks.com/help/matlab/ref/switch.html

    switch switch_expression, case case_expression, end evaluates an expression and chooses to execute one of several groups of statements. Each choice is a case. The switch block tests each case until one of the case expressions is true. A case is true when: For numbers, case_expression == switch_expression.