Conditional Indexing Using Specific Numbers in A Column

조회 수: 2 (최근 30일)
SRB
SRB 2020년 5월 17일
답변: Jyotsna Talluri 2020년 5월 26일
I have the following 2156 x 11 matrix (A). I have attached the matrix. I want to use column 11 to get all rows between 5001's and 6001's and put them in another matrix (B). I also want to get all the rows between 5001's and 1001's and put them in another matrix (C).
Below is a truncated version of column 11:
1001
0
0
0
0
0
0
5001
1001
0
0
0
0
0
5001
1001
0
0
0
0
5001
0
1001
0
0
0
0
5001
1001
0
0
0
0
5001
6001
.
.
.
  댓글 수: 2
Jyotsna Talluri
Jyotsna Talluri 2020년 5월 25일
Is first 5001 and last 6001 of 11th column to be considered ?
SRB
SRB 2020년 5월 25일
Yes.

댓글을 달려면 로그인하십시오.

답변 (1개)

Jyotsna Talluri
Jyotsna Talluri 2020년 5월 26일
load('MyData.mat');
a=find(MyData(:,11)==5001);
b=find(MyData(:,11)==6001);
matrixA=MyData(a(1):b(end),:);

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by