How to find rearrange these values in a new row and column?
조회 수: 1 (최근 30일)
이전 댓글 표시
Mohammad Danial Bin Kamarul Zaman
2019년 2월 15일
댓글: Mohammad Danial Bin Kamarul Zaman
2019년 2월 15일
For example: I have the following array of data.
column 1 column 2
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
I would like to make a new array of data sets with
column 1 column 2
2 3
4 5
5 6
8 9
What would be the best command to rearrange the matrix?
댓글 수: 0
채택된 답변
Star Strider
2019년 2월 15일
One approach:
A = [1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9];
L = ismember(A(:,1), [2 4 5 8]);
B = A(L,:)
produces:
B =
2 3
4 5
5 6
8 9
댓글 수: 0
추가 답변 (1개)
참고 항목
카테고리
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!