MATLAB Answers

insert zeros into vector

7 views (last 30 days)
Liron Sabatani
Liron Sabatani on 14 Apr 2020
Commented: Stephan on 14 Apr 2020
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!

  0 Comments

Sign in to comment.

Accepted Answer

Stephan
Stephan on 14 Apr 2020
a = [1 2 3 4 5]
b = zeros(4,numel(a))
result = reshape([a; b],1,[])

  2 Comments

Liron Sabatani
Liron Sabatani on 14 Apr 2020
thank you king!
Stephan
Stephan on 14 Apr 2020
Did you notice that you can accept and or vote for useful answers?

Sign in to comment.

More Answers (0)