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 nth element equal 0.

arrays matlab

Comments

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -