Spread the "1 logic" by one bit to the left and one bit to the right of a given logic vector

1 回表示 (過去 30 日間)
I want to create a small function that transform this vector
A = [0 0 1 1 0 0]
to B = f(A), where
B = [0 1 1 1 1 0]
so, what it does is: it spreads the 1's one bit to the left and 1 bit to the right.
Another example is
AA = [0 0 0 1 0 0 1 0 0 0 1 1 0 0]
will be
BB = [0 0 1 1 1 1 1 1 0 1 1 1 1 0]
I am unable to express what this function does rather than giving example.
Help please!

採用された回答

Image Analyst
Image Analyst 2019 年 2 月 24 日
Try movmax() or imdilate
B = movmax(A);
B = imdilate(A, [1,1,1]);

その他の回答 (0 件)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by