How can I calculate the cumulative sum of this file?

1 回表示 (過去 30 日間)
Pul
Pul 2021 年 12 月 1 日
編集済み: Pul 2021 年 12 月 2 日
Hello everyone,
I should calculate the cumulate of the column 4, from 2015 until 2020. How can I do it?
Thank you!

採用された回答

Steven Lord
Steven Lord 2021 年 12 月 1 日
"calculate the cumulative" what of the file?
Cumulative sum? cumsum.
Cumulative product? cumprod.
Cumulative minimum or maximum? cummin and cummax.
  5 件のコメント
Steven Lord
Steven Lord 2021 年 12 月 2 日
Can you show:
whos DATIECMWFgiornalieri
I'm assuming the comma inside the cumsum call is a typo, as otherwise that code would have thrown an error.
If I'm right and DATIECMWFgiornalieri is a table or timetable array, extract the contents of the fourth variable using curly braces instead of extracting the fourth variable as a sub-table using parentheses.
load patients
T = table(LastName, Height, Weight, Age);
head(T) % Show only the first few rows
ans = 8×4 table
LastName Height Weight Age ____________ ______ ______ ___ {'Smith' } 71 176 38 {'Johnson' } 69 163 43 {'Williams'} 64 131 38 {'Jones' } 67 133 40 {'Brown' } 64 119 49 {'Davis' } 68 142 46 {'Miller' } 64 142 33 {'Wilson' } 68 180 40
C1 = cumsum(T{:, 4}) % Cumulative sum of the Age variable
C1 = 100×1
38 81 119 159 208 254 287 327 355 386
C2 = cumsum(T(:, 4)) % Will error as cumsum is not defined for table arrays
Error using cumsum
Invalid data type. First input argument must be numeric or logical.
Pul
Pul 2021 年 12 月 2 日
編集済み: Pul 2021 年 12 月 2 日
Yes, got it, thank you.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by