incremental sum in array

조회 수: 1 (최근 30일)
ANAND ASP
ANAND ASP 2021년 2월 9일
답변: Jan 2021년 2월 9일
A=[45 48 63 84 32]
B=[272 227 179 116 32]
A is matrix which has some randm numbers, Matrix B is answer
Logic is, we have to start sum from last element that is 32
last second element in answer (B) is 32+84 = 116
last third element in answer (B) is 32+84+63 = 179
last fourth element in answer (B) is 32+84+63+48 = 227
last fifth element in answer (B) is 32+84+63+48+45 = 272 and so on...
  댓글 수: 1
Stephen23
Stephen23 2021년 2월 9일
What have you tried so far?

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

채택된 답변

Jan
Jan 2021년 2월 9일
A = [45 48 63 84 32]
cumsum(A, 'reverse')

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by