B = 1:11;M = 3;n = mod(numel(B),2);B((end-n:-2:end-2*M)) = 0
Standard input is empty
B = 1 2 3 4 5 0 7 0 9 0 11
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!