[TOC]

Loops

By using loops, you can perform the same set of operations repeatedly. For example, should be best computed by using a loop, because it can be obtained by performing the same operation 5 times:

a = 0;
a = a + 1;
a = a + 2;
a = a + 3;
a = a + 4;
a = a + 5;

An implementation using for-loop looks like this:

a = 0;
for i = 1:3
	a = a + i;
end

This can be easily extended to calculate the sum of many terms, such as, :

a = 0;
for i = 1:1000
	a = a + i;
end

The app provides two kinds of loops: For-loop and while-loop. The former is usually used when you know how many times a set of operations is going to be repeated. Whereas, the latter is usually used when you want to repeat a set of operations until some conditions are met. Check out the document pages "For Loop" and "While Loop" for more details.