Accumulate Connected Components

Construct array with accumulation of connected components
1.3K 次下载
更新时间 2008/9/10

查看许可证

accumconncomps creates vectors by accumulating elements in one vector using the connected components in another vector of same size. Connected components are regarded as subsequent, identical elements in a vector.

Example:
Sum the values in val according to the connected components in cc.

cc = [1 1 2 1 1 1 3 3 3 4 2 2];
val = [2.3 1.2 5 3 2 5 3.2 4.5 2 ...
2.2 1.2 2.2];

[c,valnew] = accumconncomps(cc,val,@sum)

c = 1 2 1 3 4 2
valnew = 3.5 5.0 10.0 9.7 2.2 3.4

I know, the function is rather simple, but needed it several times and perhaps others do so as well. In case you have a better way to code it, or in case you have any suggestion for an improved help text, please let me know.

引用格式

Wolfgang Schwanghart (2024). Accumulate Connected Components (https://www.mathworks.com/matlabcentral/fileexchange/21397-accumulate-connected-components), MATLAB Central File Exchange. 检索来源 .

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

Community Treasure Hunt

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

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