필터 지우기
필터 지우기

Cumulative sum of cell array column

조회 수: 4 (최근 30일)
Sherwin
Sherwin 2016년 10월 26일
댓글: Sherwin 2016년 10월 26일
Hi
I have this cell array and I need to get the cumulative sum of column 7. Please help.
A =
Columns 1 through 3
{1x39 cell} {1x75 cell} [ 7.669142585357160e-04]
{1x75 cell} {1x75 cell} [-1.206232786783515e-04]
{1x39 cell} {1x41 cell} [ 8.630787019556518e-04]
{1x41 cell} {1x65 cell} [-2.445883525841570e-05]
{1x65 cell} {1x97 cell} [ 9.109657363289406e-04]
Columns 4 through 6
[-1.206232786783515e-04] [3.231454899286823e-04] [150]
[ 0.001808452047926] [8.439143846238298e-04] [-40]
[-2.445883525841570e-05] [4.193099333486180e-04] [170]
[ 9.109657363289406e-04] [4.432534505352624e-04] [-20]
[-6.645138877833179e-04] [1.232259242728113e-04] [180]
Columns 7 through 11
[ -40] [ 55] [1x1 sym] [1x1 sym] [1x1 sym]
[ 330] [145] [1x1 sym] [1x1 sym] [1x1 sym]
[ -20] [ 75] [1x1 sym] [1x1 sym] [1x1 sym]
[ 180] [ 80] [1x1 sym] [1x1 sym] [1x1 sym]
[-140] [ 20] [1x1 sym] [1x1 sym] [1x1 sym]

답변 (2개)

Sophie
Sophie 2016년 10월 26일
편집: Sophie 2016년 10월 26일
Try this
res=sum(cellfun(@double,A(:,7)))
or
res=cumsum(cellfun(@double,A(:,7)))
  댓글 수: 1
Sherwin
Sherwin 2016년 10월 26일
Thank you so much, would you please help me to put this column vector in the first column of a S = cell(5,2)?

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


James Tursa
James Tursa 2016년 10월 26일
편집: James Tursa 2016년 10월 26일
result = cumsum(vertcat(A{:,7}));
or
result = sum(vertcat(A{:,7}));
depending on what you want.
  댓글 수: 2
Sherwin
Sherwin 2016년 10월 26일
Thank you so much!
Sherwin
Sherwin 2016년 10월 26일
Would you please help me to put this column vector in the first column of a S = cell(5,2)?

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

카테고리

Help CenterFile Exchange에서 Conversion Between Symbolic and Numeric에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by