If i have a MxN matrix, how do i add(not replace) a row of zeros and a column of zeros after every other column/row in the original matrix in matlab? Effectively the result
You can do it in the following way. Do not add the new rows and columns but create an empty matrix and fill the elements from the original matrix.
Create a new matrix with the dimensions 2Mx2N
B = zeros(2*size(A));
(assuming that A
is your original matrix). Using
B(1:2:end,1:2:end) = A;
should result in the correct new matrix.