MATLAB Answers

pramod kumar

how to add bits in between the binary data

Asked by pramod kumar
on 18 Jun 2013

P=[1 0 1 1 0 1 0 0 1 1] i need to add bits in between 250 bits in between. can some one suggest me a logic how to read each bit and then add 250 same bits and then read next bit add 250 bit my final dat should be like this p1=[1 ....(250 one ) then 0------(250 zeros) then 1.......(250 one).................]



No products are associated with this question.

1 Answer

Answer by Andrei Bobrov
on 18 Jun 2013
Edited by Andrei Bobrov
on 18 Jun 2013

out = reshape(ones(251,1)*P(:)',1,[]);


out = kron(P(:)',ones(1,251));


the bit we are adding it is adding in the next colum but the bit should add in between P[1 0 1] we are creating a matrix it should add in between the bits but we are creating < 255x250 double> 1 1 1 1 0 0 0 0 1 1 1 1

thank you so much its helped me lot

Join the 15-year community celebration.

Play games and win prizes!

Learn more
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!