Index from one vector to different sized vector
조회 수: 2 (최근 30일)
이전 댓글 표시
I have a 582x1 column vector and a 3190x2 matrix. I want to extract only those rows of the matrix whose column 1 entry has the same value as any entry in the 582 vector. I can't figure out how to index in this way. I tried changing the size of the column vector to 3190, but it still only compared the entries with the same indexes.
댓글 수: 0
채택된 답변
추가 답변 (1개)
Asad (Mehrzad) Khoddam
2020년 9월 12일
% v1 the first vector
% v2 the matrix
[~, ~, i2] = intersect(v1, v2(:,1));
newMatrix = v2(t2,:);
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!