If you have an array of symbolic variables in MATLAB and you want to find their sum, you can use the symsum function. Here's an example:
main.m41 chars4 lines
In this example, we first define three symbolic variables x, y, and z, and then create an array A that contains those variables. We then use the symsum function to sum up the values in A, which gives us the symbolic expression x + y + z.
Note that symsum can also take additional arguments to specify the range of the sum, for example:
main.m19 chars2 lines
will sum up the values in A from k=1 to k=n.
gistlibby LogSnag