Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
For Loops | Coding Foundations
Matlab From Beginner to Professional
course content

Contenido del Curso

Matlab From Beginner to Professional

Matlab From Beginner to Professional

1. Basic Syntax And Coding With A Text Editor
2. Coding Foundations
3. Learning Through Applications
4. Visualizations
5. Recursion + Matrix Multiplication

bookFor Loops

What happens when we want to program reasonably similar tasks for hundreds of different lines of data? Are we going to write a program with 900 lines of code? No! We'll use for loops!

By translating our tasks into for loops, we can have a few lines of code execute billions of tasks. And when combined with if statements (next chapter), we can really start to analyze data in complex and efficient ways.
Here we'll dip our toes in by learning the general behavior and logical errors that can arise. The syntax isn't super complicated, so you can start off with the set of snippets until you have it down, and in the next section we'll start using for loops to analyze data in real world applications.

Task

Write a program with a nested for loop that:

  • Creates a blank matrix;
  • Assigns entry (i, j) of the blank matrix to i (j-1) for 1 ≤ i ≤ 7 and 1 ≤ j ≤ 7.

¿Todo estuvo claro?

¿Cómo podemos mejorarlo?

¡Gracias por tus comentarios!

Sección 2. Capítulo 3
We're sorry to hear that something went wrong. What happened?
some-alt