Zero padding/stuffing in matlab -
basicly have array this:
[1 2 3 4 5 6]
i want have array this:
[1 0 2 0 3 0 4 0 5 0 6]
so l-1
zeros in array l
number of values inside array before 0 stuffing.
anyone have idea how solve in matlab?
you can try this:
a = [1 2 3 4 5 6]; b = zeros(1, 2 * length(a) - 1); b(1:2:end) = a;
this results in
b = 1 0 2 0 3 0 4 0 5 0 6
a shorter version suggested dan in comments:
b(1:2:2 * length(a) - 1) = a;
Comments
Post a Comment