フィルターのクリア

For given vector, make a "averaged vector"

1 回表示 (過去 30 日間)
JaeSung Choi
JaeSung Choi 2017 年 12 月 17 日
編集済み: Jan 2017 年 12 月 17 日
For a given 1 by 1000 vector A = (a1 a2 a3 a4 so on,,a1000) and interger n
I want to make vector
B = (b1 b2 b3 so on,,b(1000-n+1))
with b1 = a1 + a2 + a3 ...+a(n), b2 = a2 + a3 + ....+a(n+1), b(1000-n+1) = a(1000-n+1)+a(1000-n+2)+...a(1000)
Please help me. How can i make such vector B??

採用された回答

Jan
Jan 2017 年 12 月 17 日
編集済み: Jan 2017 年 12 月 17 日
b = movsum(a, [0, n], 'Endpoints', 'discard')

その他の回答 (1 件)

Walter Roberson
Walter Roberson 2017 年 12 月 17 日
temp = [0, cumsum(A)];
B = temp(n+1:end) - temp(1:end-n);

カテゴリ

Help Center および File Exchange데이터형 についてさらに検索

Community Treasure Hunt

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

Start Hunting!