File Exchange

image thumbnail

nones

version 1.2 (1.91 KB) by Jos (10584)
fill each row/column with a certain number of ones (N-ONES)

3 Downloads

Updated 18 Feb 2019

View Version History

View License

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

Cite As

Jos (10584) (2021). nones (https://www.mathworks.com/matlabcentral/fileexchange/10622-nones), MATLAB Central File Exchange. Retrieved .

Comments and Ratings (2)

Jos x

Thanks Matt, the help text will be corrected.
Jos

Matt Fig

Works well, however there is an error in the help... the second paragraph is inacurate.

nones([1 0 4])' matches the description, not
nones([1 0 4]).

MATLAB Release Compatibility
Created with R2018b
Compatible with any release
Platform Compatibility
Windows macOS Linux
Acknowledgements

Inspired: padcatcell

Community Treasure Hunt

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

Start Hunting!