Select value with constant interval
조회 수: 6 (최근 30일)
이전 댓글 표시
Hi everyone, I need select values with constant interval from a certain column of a matrix. 3rd, 6th, 9th... like that. I must extract and create a new vector by them. I have not met any topic related to my problem. Can you help me?
댓글 수: 0
답변 (1개)
Star Strider
2017년 7월 8일
Example —
M = randi(9, 10, 4); % Create Matrix
Col = 3; % Choose Column
Out = M(3:3:end, Col); % Selected Rows From Specified Column
댓글 수: 2
Les Beckham
2017년 7월 8일
Re-read the documentation on the colon operator (especially the second form of the Syntax examples). Star provided the correct answer and an example matching the example in your question. Perhaps if the last line of the example was written as follows it would clarify things:
Out = M(startIndex:interval:end, Col);
참고 항목
카테고리
Help Center 및 File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!