MATLAB: Insert zeros into vector insert zerospad zeroszeros I have an array of coeffecients [a1,a2,a3,…,an] and I want to insert 4 zeros between each one. the wanted result: [a1,0,0,0,0,a2,0,0,0,0,a3,0,0,0,0,…,0,0,0,0,an] thank's for help! Best Answer a = [1 2 3 4 5]b = zeros(4,numel(a))result = reshape([a; b],1,[]) Related SolutionsMATLAB: Code to generate matrix You can put it together using diag()d0 = [repmat(4,1,8), 5, repmat(4,1,8), 5, repmat(3,1,8)];d1 = ones(1, length(d0)-1);d9 = ones(1, length(d0)-9);A = diag(d0,0) + diag(d1, -1) + diag(d1, 1) + diag(d9, -9) + diag(d9, 9);b = [zeros(1,17), 5, zeros(1, 7), 5]; MATLAB: Inserting Image This might help:http://blogs.mathworks.com/pick/2007/10/16/matlab-basics-setting-a-background-image-for-a-gui/ Related QuestionDid the matrix symbol become 10×10Insert zeros in a vectorHow to “smear” a logical mask without loopingInserting Zeros in a MatrixAdd column vector with for loopsInsert zeros into matrix in matlabIllegal use of reserved keyword “end”
Best Answer