Write a function to determine which elements of an array are even numbers (i.e., …, -4, -2, 0, 2, 4, …). Your function should return a logical array of the same size as the input with 1s (TRUE) in the locations corresponding to even numbers.
6 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Meesha Lini Eesan
le 24 Mar 2015
Réponse apportée : Meesha Lini Eesan
le 24 Mar 2015
How could I solve this?
0 commentaires
Réponse acceptée
Konstantinos Sofos
le 24 Mar 2015
funvtion Out = findeven(In)
Out = ~mod(In,2)
end
Assuming:
In =
-6 -5 -2 0
1 2 3 4
5 6 7 8
9 10 11 12
Out =
1 0 1 1
0 1 0 1
0 1 0 1
0 1 0 1
0 commentaires
Plus de réponses (1)
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!