About 304,000 results
Open links in new tab
  1. Loops and Conditional Statements - MATLAB & Simulink

    while loop to repeat when condition is true: try, catch: Execute statements and catch resulting errors: break: Terminate execution of for or while loop: return: Return control to invoking script …

  2. Loop Control Statements - MATLAB & Simulink - MathWorks

    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 …

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

    If you inadvertently create an infinite loop (that is, a loop that never ends on its own), stop execution of the loop by pressing Ctrl+C. If the conditional expression evaluates to a matrix, …

  4. How do I create a for loop in MATLAB? - MATLAB Answers

    Mar 5, 2012 · 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 …

  5. for - for loop to repeat specified number of times - MATLAB

    To programmatically exit the loop, use a break statement. To skip the rest of the instructions in the loop and begin the next iteration, use a continue statement. Avoid assigning a value to the …

  6. if - Execute statements if condition is true - MATLAB - MathWorks

    Loop through the matrix and assign each element a new value. Assign 2 on the main diagonal, -1 on the adjacent diagonals, and 0 everywhere else.

  7. colon - Vector creation, array subscripting, and for-loop iteration ...

    In the context of a for-loop, the colon specifies the loop iterations. Write a for -loop that squares a number for values of n between 1 and 4. for n = 1:4 n^2 end

  8. How to make dynamic variable names (A1, A2, ..., An) with "for" …

    Nov 13, 2013 · I want to use a loop to define the equations for each set of objects at rest and in motion, and skip having to write them one by one. Also the number of objects is an initial input …

  9. Matlab - Writing Text and Numeric Data to a File in a Loop

    Aug 22, 2013 · The numeric matrix is of same size as cell matrix and represents the values corresponding to names in cell matrix. Hence, for this loop it has size 1x5 and stores values …

  10. How do I iterate through each element in an n-dimensional matrix …

    The linear index applies in general to any array in matlab. So you can use it on structures, cell arrays, etc. The only problem with the linear index is when they get too large. MATLAB uses a …