LOGICALEXPAND

版本 1.0.0.0 (2.2 KB) 作者: Jos (10584)
expand (or shrink) series in a logical vector (v2.0, feb 2014)
262.0 次下载
更新时间 2014/3/3

查看许可证

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)

引用格式

Jos (10584) (2025). LOGICALEXPAND (https://ww2.mathworks.cn/matlabcentral/fileexchange/45728-logicalexpand), MATLAB Central File Exchange. 检索时间: .

MATLAB 版本兼容性
创建方式 R2011a
兼容任何版本
平台兼容性
Windows macOS Linux
类别
Help CenterMATLAB Answers 中查找有关 Shifting and Sorting Matrices 的更多信息

Community Treasure Hunt

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

Start Hunting!
版本 已发布 发行说明
1.0.0.0