selecting different criteria for logicals

1 visualizzazione (ultimi 30 giorni)
Cside
Cside il 28 Ago 2019
Commentato: Cside il 30 Ago 2019
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! :)

Risposta accettata

Rik
Rik il 28 Ago 2019
L=data(:,1)==2 & data(:,2)==3;
  6 Commenti
Rik
Rik il 28 Ago 2019
%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 il 30 Ago 2019
Thank you! I got it :)

Accedi per commentare.

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by