About 37,600,000 results
Open links in new tab
  1. 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. for r = 1:nrows. if r == c. A(r,c) = 2; elseif …

  2. MATLAB - Conditional Statements - GeeksforGeeks

    Nov 26, 2020 · Unlike other programming languages, we don't use any kind of parentheses (i.e., (),{},: ) while writing conditions in conditional statements(i.e., if, nested if, etc). We do use end …

  3. Practical 4: For- and While- Loops, If-statements | learnonline

    4 days ago · Create a for-loop to repeatedly execute statements a fixed number of times. Create a while- loop to execute commands as long as a certain condition is met. Use relational and …

  4. For Loop with If Statement in MATLAB - YouTube

    In this video, we will learn how to use a for loop with an if statement. It shows an example in MATLAB about using the conditional operators. In case you wan...

  5. How to Use the if Statement in MATLAB - dummies

    The if statement makes it possible to either do something when the condition you provide is true or not do something when the condition you provide is false. The following steps show how to …

  6. Control Flow in MATLAB - If Statements and Loops

    In this guide, we'll explore how to use if statements and loops in MATLAB with sample code. If statements are used to execute code conditionally. Here's an example of an if statement: …

  7. Loops and Conditional Statements - MATLAB & Simulink

    To determine which block of code to execute at run time, use if or switch conditional statements. To repeatedly execute a block of code, use for and while loops.

  8. if statements inside a for loop in Matlab - Stack Overflow

    Apr 3, 2017 · I am trying to understand how I can use if statements inside a for loop in Matlab. I d like my Go[] array be like this [1,1,1,1,1,2,3,3,3,3] instead of the image's results …

  9. Understanding if statements in MATLAB for loops: A Common …

    Explore how to properly use `if` statements within `for` loops in MATLAB to avoid unexpected outputs, with a focus on logical operators for correct compariso...

  10. Using the if Statement in a for Loop in MATLAB - Stack Overflow

    Aug 4, 2021 · Question: How do I correct the if statement to display all the lines and count those lines crossing y = 0? for j = 1:length(GLines) axis square. ylim([-5 5]); xlim([-5 5]); y = …

  11. Some results have been removed