selecting different criteria for logicals

1 次查看(过去 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;

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Title 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by