Sum of elements of a multidimensional symbolic array
4 views (last 30 days)
Show older comments
Farid Salazar Wong
on 24 Jun 2015
Commented: Farid Salazar Wong
on 24 Jun 2015
I have a multidimensional array whose entries are polynomials. I would like to obtain the sum of all elements in the array. I know that is it is a vector is just need to use sum, if it is a matrix I would use sum twice, if it is a 3 array I would use sum three times and so on. In MATLAB, it worked fine up to a matrix, but when I tried the command sum for a 3 array it gave me the message:
Error using mupadmex Error in MuPAD command: Input arguments must be 2-D.
Error in sym/privUnaryOp (line 826) Csym = mupadmex(op,args{1}.s,varargin{:});
Error in sym/sum (line 59) s = privUnaryOp(A, 'symobj::prodsum', '_plus');
Is there any way around this?
0 Comments
Accepted Answer
Azzi Abdelmalek
on 24 Jun 2015
Edited: Azzi Abdelmalek
on 24 Jun 2015
syms x
a(1,1,1)=x
a(1,1,2)=x^2
a(1,1,3)=x^3
out=sum(a(:))
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!