Extracting intervals from an array to create a new array

2 ビュー (過去 30 日間)
Martin Hansen
Martin Hansen 2019 年 4 月 17 日
コメント済み: Martin Hansen 2019 年 4 月 17 日
Hi,
I'm trying extract a series of intervals from an array to create a new array, where it is the sum of these individual intervals.
For example I have a 100x1 array, would like to divide it in such that every 5 number is in a group. Then a new array should be created, which contains the sums of all these intervals (which should end up being a 20x1 array).
I've tried to solve it with a "for function", but can't really seem to get it working. Any help or hints would be highly appreciated :)
Best regards

回答 (1 件)

madhan ravi
madhan ravi 2019 年 4 月 17 日
sum(reshape(array,[],5),2)

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

製品


リリース

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by