Is posible represent rectangular pulse in Matlab using vector?

94 Views Asked by At

I have to represent this pulses in Matlab but only when i find a 0 in a vector

enter image description here

This is my code, i generate a vector with 10 numbers 0s and 1s but I am not able to program the representation of the pulse when a 0 appears in the vector.

L=10;
bits = rand(1,L) < 0.5; 


dom = [1:length(bits)];

for c = length(bits):-1:2
    if bits(c) ~= 1
        bits = [bits(1:c-1), bits(c-1:end)];
        dom = [dom(1:c),dom(c:end)];
    end

end
figure(2)
plot (dom,bits)
0

There are 0 best solutions below