How to find the derivative without using a symbolic function in Matlab?

How to achieve summation for elements of a matrix using MatLab (symsum) function?

  • I need to sum the values of all elements of 1st row using the summation function (symsum). How can I accomplish this? The matrix is a 512X512 one. This is the syntax: symsum(k,1,512) k is a symbol only... Can I refer it as an element? I tried inputting this: symsum[A(1,k),1,512] but got an error message ??? symsum[A(1,k),1,512] | Error: Missing operator, comma, or semicolon. Help!!!

  • Answer:

    symsum has usage like symsum(a,b,c) (not symsum[a,b,c]), thus your expression cannot be computed and the reason for the error message. Also note that you are summing the first column of the matrix. Since you have not said exactly what kind of summation over the matrix I will assume you would like to sum each column. a is an expression. b is the starting value. c is the ending value. b and c should be integers. What this function does is it will use findsym to guess what your symbol is in the expression a. (normally it finds the variable that is closest to x). Then it will sum by plugging in all the integers between a and b inclusive. The following code and result are given from the help file. syms x k %defines the symbols s1 = symsum(1/k^2,1,inf) %1+1/4+1/9+1/16+... s2 = symsum(x^k,k,0,inf) %This has an extra input that defines %the variable being used as k instead of x which is obviously %closer to x that findsym is looking for. %1+x+x^2+x^3+... Output: s1 = 1/6*pi^2 s2 = -1/(x-1) Clearly this is only to be used if your value for a is an expression. It is rather odd to use symsum to sum over an index of A. For example sum(A(1,:)) is a much simpler way to sum in this case. My guess is that you have probably evaluated your expression down the first column and you want to do part of symsum's work for it. In that case you can just type sum(A,1). This will return a vector of 512 columns and 1 row and the sum of each column of A will be there. Now I am still unsure of what you are attempting to sum, but lets say you are trying to sum 512 different expressions simultaneously. Let B be a 512x1 vector of expressions containing the summation variable x, your code should look like this: syms x; B=[x;x^2;1/x;...];%insert some functions of x here symsum(B,1,512); I think I have pretty much covered all your possible cases briefly. If you can give me more info on your exact problem I can reply with more detailed information for that case. Josh

Joe at Yahoo! Answers Visit the source

Was this solution helpful to you?

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.