I have a vector X of size 30 by 1 and I need to divide/group the elements (say the first two forms the first group third and fourth the second group and so on). Now I need to specifically check to which group a particular number (which is an element of X) belongs to and would like to get the index of that number (index when the number belongs to X, say for eg, it was the 15th number in X). Could anyone please help me sort this out.

 채택된 답변

David Hill
David Hill 2021년 10월 27일

0 개 추천

x=randi(100,30,1);
X=reshape(x,2,[]);
[~,idxGroup]=find(X==x(15));

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Matrix Indexing에 대해 자세히 알아보기

제품

릴리스

R2019b

질문:

2021년 10월 27일

댓글:

2021년 10월 27일

Community Treasure Hunt

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

Start Hunting!

Translated by