Clear Filters
Clear Filters

multiple conditions in matrix

4 views (last 30 days)
abdul rehman
abdul rehman on 10 Jul 2021
Commented: abdul rehman on 10 Jul 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, :)

Accepted Answer

Simon Chan
Simon Chan on 10 Jul 2021
Edited: Simon Chan on 10 Jul 2021
Do you want this?
d=C(C(:,2) == 1 & C(:,3) == 2)
  2 Comments
Jonas
Jonas on 10 Jul 2021
probably
d=C(C(:,2) == 1 & C(:,3) == 2,:)

Sign in to comment.

More Answers (0)

Categories

Find more on Multidimensional Arrays in Help Center and File Exchange

Products


Release

R2021a

Community Treasure Hunt

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

Start Hunting!