How do you make every other integer in an array equal to 0 in matlab? -
How do you make every other integer in an array equal to 0 in matlab? -
lets have array
y = [1, 2, 3, 4, 5, 6]
i want create new array replaces every other number 0, creates
y = [1, 0, 3, 0, 5, 0]
how go approaching , writing code in efficient way?
this should that:
y(2:2:end) = 0;
with line each element starting seconds last, in steps of two, should zero. can done larger steps too:, y(n:n:end) = 0
makes every n
th element equal 0.
arrays matlab
Comments
Post a Comment