multiple conditions in matrix

13 vues (au cours des 30 derniers jours)
abdul rehman
abdul rehman le 10 Juil 2021
Commenté : abdul rehman le 10 Juil 2021
I am receiving this error while applying multipe conditions in matrix
Code:
C= [rand(100,1),randi([0,2],100,1),randi([0,2],100,1),randi([5,12],100,1)]
d=C(C(:,2) == 1,: && (:,3) == 2, :)

Réponse acceptée

Simon Chan
Simon Chan le 10 Juil 2021
Modifié(e) : Simon Chan le 10 Juil 2021
Do you want this?
d=C(C(:,2) == 1 & C(:,3) == 2)
  2 commentaires
Jonas
Jonas le 10 Juil 2021
probably
d=C(C(:,2) == 1 & C(:,3) == 2,:)
abdul rehman
abdul rehman le 10 Juil 2021
yes exactly

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Multidimensional Arrays dans Help Center et File Exchange

Produits


Version

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by