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

Réponses (1)

James Tursa
James Tursa le 2 Août 2016

0 votes

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 commentaires

ahmed sengab
ahmed sengab le 3 Août 2016
thanks
Sulaymon Eshkabilov
Sulaymon Eshkabilov le 8 Sep 2020
sum(V, 4) works ok! but reshape() thing gives a size related error.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Symbolic Math Toolbox dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by