Selecting sequence of data of column vector

1 回表示 (過去 30 日間)
Willemijn Wolf
Willemijn Wolf 2016 年 8 月 16 日
編集済み: Stephen23 2016 年 8 月 16 日
I've got a column vector with length 5000, each row containing a binary results (0 or 1). I need to calculate the sum of the 1st, 6st, 11th, 16th, ... but I don't know how to select those 1st, 6st, 11th, ... datapoints. Can someone help me? Thanks!

回答 (1 件)

Stephen23
Stephen23 2016 年 8 月 16 日
編集済み: Stephen23 2016 年 8 月 16 日
Just use indexing:
sum(vector(1:5:end))
This is very basic MATLAB usage, which is taught well in the introductory tutorials:

カテゴリ

Help Center および File ExchangeGet Started with MATLAB についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by