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
If you are looking for efficiency it can never hurt to try various options. Here is another way to do it:
M = magic(5)>3; % Example matrix
positions = [2 3 6]; % Desired padding columns in resulting matrix
n = size(M,2)+numel(positions);
R = false(size(M,1),n);
R(:,setxor(positions,1:n))=M