Symbolic 4D array

I have a symbolic 4D array V(i,j,k,l). I want to sum over the l component to reduce it to 3D. I tried x(i,j,k)=sum(V(i,j,k,:)) but it is not working. Any advice

Respuestas (1)

James Tursa
James Tursa el 2 de Ag. de 2016

0 votos

Not sure why sum(V,4) doesn't work, but reducing it to 2D with some reshapes seems to work:
z = size(V);
x = reshape(sum(reshape(V,[],z(end)),2),z(1:end-1));

2 comentarios

ahmed sengab
ahmed sengab el 3 de Ag. de 2016
thanks
Sulaymon Eshkabilov
Sulaymon Eshkabilov el 8 de Sept. de 2020
sum(V, 4) works ok! but reshape() thing gives a size related error.

Iniciar sesión para comentar.

Categorías

Más información sobre Symbolic Math Toolbox en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 28 de Jul. de 2016

Comentada:

el 8 de Sept. de 2020

Community Treasure Hunt

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

Start Hunting!

Translated by