Sum of elements of a multidimensional symbolic array

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?

 Respuesta aceptada

Azzi Abdelmalek
Azzi Abdelmalek el 24 de Jun. de 2015
Editada: Azzi Abdelmalek el 24 de Jun. de 2015
syms x
a(1,1,1)=x
a(1,1,2)=x^2
a(1,1,3)=x^3
out=sum(a(:))

Más respuestas (0)

Categorías

Más información sobre Mathematics en Centro de ayuda y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by