check if elements in an array are equal to 0 1 or 2
Show older comments
i have been given a random sqaure matrix. how do i check that all the elements witihin my array are equal to 0,1 or 2?
Accepted Answer
More Answers (1)
madhan ravi
on 21 Nov 2018
a=randi([0 2],2)
unique(a(:)) %returns unique numbers in a matrix
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!