Trying to make every odd number zero in a vector

8 vues (au cours des 30 derniers jours)
Christopher Maksimowicz
Christopher Maksimowicz le 5 Déc 2019
I have a variable x = 1:100;
I am trying to make the y have every odd number be zero, how do I do that?

Réponses (1)

Bhaskar R
Bhaskar R le 5 Déc 2019
x(find(mod(x, 2))) = 0;
or
x(1:2:end) = 0;

Catégories

En savoir plus sur Data Types dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by