Зміст курсу
Matlab From Beginner to Professional
Matlab From Beginner to Professional
For 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.
Дякуємо за ваш відгук!