I need to pad zeros to specific locations in binary numbers. Looping the array form of a binary number such as dec2bin(43) and adding the zeros and adjusting th
You can do it using just indexing. The positions of the zeros to be inserted in the extended vector are insertzeros+(1:length(insertzeros)) (where insertzeros is [1 3 6] in your example):
input = [1 0 1 0 1 1]; %// example data
insertzeros = [1 3 6]; %// example data
output = ones(1,length(input)+length(insertzeros));
output(insertzeros+(1:length(insertzeros))) = 0;
output(output==1) = input;