LOGICALEXPAND
Y = LOGICALEXPAND(X,N) returns a logical vector Y of the same length as the vector X.
For N > 0, series of true entries in X are expanded with N values on either side. For N < 0, series of true entries in X are shrinked with N values on either side. For N = 0, Y equals logical(X).
Examples:
% expand by 1
logicalexpand(logical([0 0 0 1 0 0 0 1 1 0 0 0 1]), 1)
% -> [0 0 1 1 1 0 1 1 1 1 0 1 1]
% shrink with 2
logicalexpand(logical([0 1 1 1 1 1 1 0 0 0 1 1 1 1 1]).', -2)
% -> [0 0 0 1 1 0 0 0 0 0 0 0 1 0 0].'
See also find, logicalfind (File Exchange)
Cite As
Jos (10584) (2024). LOGICALEXPAND (https://www.mathworks.com/matlabcentral/fileexchange/45728-logicalexpand), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Platform Compatibility
Windows macOS LinuxCategories
Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.
Version | Published | Release Notes | |
---|---|---|---|
1.0.0.0 |