Did you check the output first?
Val=[double(logical(1:5)) 0] % double converts other classes to double and the array at the end is padded with zero
doc double % read it
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!