Summation operations of regular serials are a very important aspect of calculus and engineering maths. Matlab® provides a very useful command that you can easily perform serial sums in Matlab®. The command is the ‘symsum()’ command.
Here we explain how to use the ‘symsum()’ command to calculate serial sums in Matlab® easily. The example below is executed in the Matlab® command window. So, you can try it in your own Matlab® software.
>> syms n symsum(n*n,3,23) ans = 4319 >>
As you see in the example above, firstly we created our symbolic variable ‘n’ with the ‘syms’ command. We can use this variable inside our main code to obtain our equations.
In the ‘symsum()’ command, the first term is the equation that we want to calculate its serial sum, which is ‘n*n’ in this example.
The second term is the starting value of the serial sum which is ‘3’ and the third term is the last value that serial sum ends, which is ’23’ here.
If you hit the ‘Enter’ key to execute code in the Matlab® command window, you will see the result as above.
>> syms n x symsum(n*n,3,x) ans = (x*(2*x + 1)*(x + 1))/6 - 5 >>
You can also make symbolic operations with the ‘symsum()’ command. We created two symbolic variables which are ‘x’ and ‘n’. And we wrote the ‘x’ as the last term. This will give us the general equation that any number will give the exact result.
As you see above, solving the serial sums in Matlab® is very simple with the ‘symsum()’ command.
Do not forget to leave your comments and questions below about the ‘symsum()’ command in Matlab® below.
YOU CAN LEARN MatLab IN MECHANICAL BASE; Click And Start To Learn MatLab!
If you want further coding examples about the ‘symsum()’ command in Matlab®, inform us in the comments.
This article is prepared for completely educative and informative purposes. Images used courtesy of Matlab®