The problem is in similar wave duration time and sampling time. You may increase your rate of simulation or slow your waveform. Instead using:
signal=[0 1 0 1 1 1 0 0 1];
try
signal=[0 0 0 1 1 1 0 0 0 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 1 1 1];
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!