Write your own 'sum' function Now, take a look at Example 2. This is the most basic way to use loops to perform calculations. MATLAB's built-in sum function uses very similar code. As you can see, the for loop adds together all the elements of the index vector, and then outputs the sum (contained in the variable 'adder') at the end. Create an M-file called 'mySum.m', where we will write our own sum function. Remember, to write a function, the two most important things to remember are: → The filename and the function name must be the same → The first line of the function must start with the keyword 'function' To save some time, copy and paste the following lines into the top of your function 'my Sum': function S = mySum(X) %MYSUM Sum of elements % S = MYSUM(X) is the sum of the elements of the vector Write a for loop that adds up the elements of X and records the sum in S. Note, there is more than one way you can do this problem -- so just have a go and see! To check that it works, save your M-file and execute the following in your Command Window: Note, there is more than one way you can do this problem -- so just have a go and see! To check that it works, save your M-file and execute the following in your Command Window: >> mySum(1:10) ans = 55 >> mySum(11:20) ans = 155 >> mySum(1:100) ans = 5050 Once you've checked that it works, you will need your 'my Sum.m' for the next exercise. Let's say we wanted to print out status information of the loop during each iteration - copy-paste the code below into your loop (after the summing code): status = ['The current sum is ', s]; disp(status); Save and execute your code using the vector 1:10, you should get the output below: >> my Sum(1:10); T