필터 지우기
필터 지우기

How extract a submatrix out of a main matrix?

조회 수: 1 (최근 30일)
Naruto
Naruto 2020년 11월 8일
댓글: Ameer Hamza 2020년 11월 9일
I have a matrix A (50x2) and I want to extract a certain number of row observations that statisfies the condition where I output the rows that include '1' in column 2 along with another column that would state 'yes'. How can I do that?
The first column are the ID numbers and the second column would be a '1' for yes and a '0' for no.
I understand that a for loop would be applicable here but I have tried out a couple which didnt work out in adding it an extra column displayed.
thanks.

채택된 답변

Ameer Hamza
Ameer Hamza 2020년 11월 8일
Easy peasy
M_new = M(M(:,2)==1,:); % M is your n*2 matrix
  댓글 수: 2
Naruto
Naruto 2020년 11월 8일
Nice! Thanks for the link as well.
Ameer Hamza
Ameer Hamza 2020년 11월 9일
I am glad to be of help!

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

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by