About 50 results
Open links in new tab
  1. For loops vs. While loops - MATLAB Answers - MATLAB Central

    Mar 12, 2013 · The FOR loop is nicer and more compact, if the number of iterations is known before the loop is started. The WHILE loop is nicer, when the number of iterations is determined inside the loop.

  2. For-Loop vs While-Loop - MATLAB Answers - MATLAB Central

    Aug 10, 2014 · I have the code in Part1 below which stores the values of x and y after the last iteration of my while-loop. Is there a way for me to achieve to what I am trying to do in Part2; that is, to retain ...

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

    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 …

  4. if + for loops vs while loop. Same good different results

    Dec 13, 2018 · So the only difference between the two codes is that I used an if loop inside a for loop and the correct loop used only a while loop. Any ideas what could be the problem?

  5. More efficient way for doing for and while loops. - MathWorks

    Mar 1, 2014 · Hi, I understand that in matlab for loops and while loops are some-what inefficient; I was wondering if there was an alternate, more efficient way of doing loops. This would apply to just basic …

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

    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 …

  7. Loop Control Statements - MATLAB & Simulink - MathWorks

    while statements loop as long as a condition remains true. For example, find the first integer n for which factorial(n) is a 100-digit number:

  8. While or for loop? - MATLAB Answers - MATLAB Central - MathWorks

    Apr 30, 2020 · Typically, you'd use a while loop if you don't know in advance how many times you're going to loop, and a for loop if you do. Therefore in your case, a while loop would be more appropriate.

  9. Difference between a for loop and a while loop (in the context of ...

    May 5, 2021 · What is the key differences between a for loop and a while loop? I am having trouble understanding such a difference.

  10. is for loop or while loop better? - MATLAB Answers - MathWorks

    Jan 22, 2021 · Hi sir, I also studing water engineering, about "for loop" and "while loop" i prefer while specially about your homework question, my reason for that is you can do alot of things with while …