nconsecutive

版本 1.0.0.0 (1.4 KB) 作者: Brett Shoelson
Returns a vector containing the maximum number of consecutive integers in each row of matrix x.
2.4K 次下载
更新时间 2001/11/5

查看许可证

NCONSEC = NCONSECUTIVE(X) returns a vector containing the maximum number of consecutive integers in each row of matrix x.

Note that while this code is not vectorized, it was tested against two different vectorized versions; the for-loop code ran about twice as fast as the vectorized versions.

Example:
nconsec = nconsecutive([1 2 3 5 6 7; 8 7 6 2 4 1; 2:7; 9:-1:5 5])

Editor's Note: You might want to try vectorizing this to work along the columns instead of along the rows; since MATLAB is column major this may be more effective.

引用格式

Brett Shoelson (2024). nconsecutive (https://www.mathworks.com/matlabcentral/fileexchange/1006-nconsecutive), MATLAB Central File Exchange. 检索来源 .

MATLAB 版本兼容性
创建方式 R12.1
兼容任何版本
平台兼容性
Windows macOS Linux

Community Treasure Hunt

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

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