nones

版本 1.2 (1.9 KB) 作者: Jos (10584)
fill each row/column with a certain number of ones (N-ONES)
1.8K 次下载
更新时间 2019/2/18

查看许可证

NONES - fill each row/column with a certain number of ones (N-ONES)
A = NONES(V) creates a logical array A, in which each row/column
starts with zero or more TRUE entries followed by zero or more FALSE
entries, as specified by the elements of the vector V.

Examples
nones([1 0 4]) % ->
1 0 1
0 0 1
0 0 1
0 0 1

a = nones([-2 3 2 7].') ;
b = cumsum(a,2) ;
b(~a) = 0 % ->
0 0 0 0 0 0 0
1 2 3 0 0 0 0
1 2 0 0 0 0 0
1 2 3 4 5 6 7

引用格式

Jos (10584) (2025). nones (https://www.mathworks.com/matlabcentral/fileexchange/10622-nones), MATLAB Central File Exchange. 检索时间: .

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

Community Treasure Hunt

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

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

modernised, add image

1.0.0.0

version 1.1 (may 2006) corrected small error in help text (thank to MF)