To do summation, you can use a FOR loop for the given expression by indexing the main function to any number of items you want. In your case, it is from 1 to N-1. So, N-1 times is the limit in your FOR loop program. If you just plug in our function and give an index i in your main function where i = 1 to N-1, you should be able to get your desired output.
Alternatively, you can also use WHILE loop. It is very similar to the functionality of FOR loop except that the syntax is a bit different. If you want to use a material for your reference, I would recommend the following link,
https://www.mathworks.com/help/matlab/ref/for.html for FOR loop, and
https://www.mathworks.com/help/matlab/ref/while.html, for WHILE loop.
you can use a loop for a given expression by indexing the main function for any desired object. In your case, it ranges from 1 to n-1. So, n - 1 is your limit for a loop program. If you plug in our function and give an index to your main function, where i = 1 to n - 1, you should be able to get your desired output.