Trying to make every odd number zero in a vector

7 次查看(过去 30 天)
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?

回答(1 个)

Bhaskar R
Bhaskar R 2019-12-5
x(find(mod(x, 2))) = 0;
or
x(1:2:end) = 0;

类别

Help CenterFile Exchange 中查找有关 Data Types 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by