Selecting sequence of data of column vector

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일

1 개 추천

Just use indexing:
sum(vector(1:5:end))
This is very basic MATLAB usage, which is taught well in the introductory tutorials:

카테고리

도움말 센터File Exchange에서 Data Type Conversion에 대해 자세히 알아보기

질문:

2016년 8월 16일

편집:

2016년 8월 16일

Community Treasure Hunt

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

Start Hunting!

Translated by