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

답변 (1개)

James Tursa
James Tursa 2016년 8월 2일

0 개 추천

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

ahmed sengab
ahmed sengab 2016년 8월 3일
thanks
Sulaymon Eshkabilov
Sulaymon Eshkabilov 2020년 9월 8일
sum(V, 4) works ok! but reshape() thing gives a size related error.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Symbolic Math Toolbox에 대해 자세히 알아보기

질문:

2016년 7월 28일

댓글:

2020년 9월 8일

Community Treasure Hunt

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

Start Hunting!

Translated by