What is the meaning in this instrument

조회 수: 1 (최근 30일)
Alaaeldin Mohamed
Alaaeldin Mohamed 2018년 2월 2일
편집: Alaaeldin Mohamed 2018년 2월 2일
I want to know the meaning of this MATLAB command
>> v = unique(m(d==1,2))
where m and d are matrices with dimensions (50x2) and (50x1) respectively.

채택된 답변

Walter Roberson
Walter Roberson 2018년 2월 2일
d == 1 where d is a vector, produces a logical vector as output -- a vector of true and false values.
When you use a logical vector as a subscript, that is called "logical indexing", and it selects for output all locations where the vector is true. In this context, those are used to select rows -- so the m(d==1,2) selects column 2 of all rows of m corresponding to the positions where d==1 is true.
v = unique(m(d==1,2))
acts the same as
temp = find(d==1);
v = unique(m(temp, 2))
  댓글 수: 1
Alaaeldin Mohamed
Alaaeldin Mohamed 2018년 2월 2일
편집: Alaaeldin Mohamed 2018년 2월 2일
Thank you very much. It works well

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Operators and Elementary Operations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by