필터 지우기
필터 지우기

How to find locations of multiple values within a matrix.

조회 수: 38 (최근 30일)
Pavel
Pavel 2015년 12월 30일
댓글: Dooyoung Kim 2018년 9월 5일
Hi, I have an array of data repeating 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10...
I need to find the locations where values equal to 1, 4, 7, 10 are found to create a subsample using those locations.
In this case it will be position 1 4 7 10 11 14 17 20 and so on.
Please, help! Thanks, Pavel

채택된 답변

Ahmed
Ahmed 2015년 12월 30일
The function ismember is what you are looking for.
x=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
y=find(ismember(x,[1, 4, 7, 10 ])),

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Structures에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by