From the course: Learning MATLAB
Unlock the full course today
Join today to access over 23,200 courses taught by industry experts.
For loops - MATLAB Tutorial
From the course: Learning MATLAB
For loops
- [Instructor] The for loop executes a group of statements in a loop for a specified number of times. For example, let's have a variable x that ranges from one to four in incremental steps of one. So let's look at the values for this variable. We will have the initial value in the first spot. We will have the incremental step in the second one and we will have the final value in the third one. So if this variable is in between values one to four, we want to calculate the power of three of these variable value which will be another variable called y equals x in power of three. To understand this better, let's see how the logic behind this works using a flow chart. So if x is equal to one, then we ask, is x higher than four, then no, continue the calculation. So the calculation of x in power of three is done and then we add one more to the variable. So x becomes x plus one, and then, now x will become two. So we again ask if x…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
Writing a program8m 37s
-
(Locked)
If/else statements5m 11s
-
(Locked)
For loops5m 46s
-
(Locked)
While loops3m 51s
-
(Locked)
Create and use a function with one input5m 3s
-
(Locked)
Create and use a function with two inputs4m 55s
-
(Locked)
Challenge: Write your first program2m 31s
-
(Locked)
Solution: Write your first program8m 14s
-
-
-