Basic Explanation Of ‘For-End’ In MatLab Programming(Illustrated Expression)

Matlab is also programming language that is used for mathematical calculations generally. Also you can use general programming language features in the Matlab programming. So you can use ‘for-end’ loop in Matlab programming when you are calculating various kinds of mathematical situations in Matlab. In this article we will show you how to use ‘For End’ loop in Matlab programming.

How To Use ‘For End’ Loop In MatLab Programming?

Very basic example for ‘For End’ loop in Matlab programming.

We preffered to explain ‘For End’ with a very basic example to teach you the logic in Matlab. If you want much more complex examples in below comments, we can prepare another article about it.

As you can see above, we types ‘for’ and an ‘a’ variable. So we equalize the variable ‘a’ to a vector as shown by green arrow above. So you need to equalize a ‘vector’ to a variable that you are using in ‘for’ loop. At each loop, the variable ‘a’ will take the each value from right to left respectively in the vector that you assigned.

So you can write your calculations inside the for-end loop. These calculations and codes will work in every loop and every values that ‘a’ will be taken. At the last element of assigned vector, the ‘a’ variable will take the last element, and the calculation inside the ‘for’code will performed last time. After that the for-end loop will over then the program go on to the following codes in Matlab.

So the last element of the vector that assigned in above example must be 9. So b = a+1; and ‘b’ is calculated according to the last value of a which is nine. So ‘b’ must be 10.

As you can see in red box above, the values of ‘a’ and ‘b’ is like that in Matlab.

So the general logic of for-end loop in Matlab programming is like that.

Leave your comments and questions below!

Share This Post! Share Tweet Share

Basic Explanation Of ‘For-End’ In MatLab Programming(Illustrated Expression) (1 Yorum)

Leave a Comment

Write your comment on this topic.