selecting different criteria for logicals

조회 수: 1 (최근 30일)
Cside
Cside 2019년 8월 28일
댓글: Cside 2019년 8월 30일
I have a 100 x 2 matrix and would need to filter those rows that has 2 in the first column, and 3 in the second column into a logical.
How should I go about this? Thank you! :)

채택된 답변

Rik
Rik 2019년 8월 28일
L=data(:,1)==2 & data(:,2)==3;
  댓글 수: 6
Rik
Rik 2019년 8월 28일
%create some data
s=struct;
for n=1:100
s(1,n).field_a=randi(10,1,1);
s(1,n).field_b=randi(10,1,1);
s(1,n).field_c=randi(10,1,1);
end
data=[s.field_b;s.field_c]';
L=data(:,1)==2 & data(:,2)==3;
Cside
Cside 2019년 8월 30일
Thank you! I got it :)

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by