matlab中如何实现这个算法?a是一个n行1列的矩阵,a=[1,1,1,0,0,0,0,0,0,0,1,1,1,0,0,0,1,0,1.];将a变为:a=[1,1,1,0,1,2,3,4,5,6,1,1,1,0,1,2,1,0,1.];

来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/19 22:18:03
matlab中如何实现这个算法?a是一个n行1列的矩阵,a=[1,1,1,0,0,0,0,0,0,0,1,1,1,0,0,0,1,0,1.];将a变为:a=[1,1,1,0,1,2,3,4,5,6,1

matlab中如何实现这个算法?a是一个n行1列的矩阵,a=[1,1,1,0,0,0,0,0,0,0,1,1,1,0,0,0,1,0,1.];将a变为:a=[1,1,1,0,1,2,3,4,5,6,1,1,1,0,1,2,1,0,1.];
matlab中如何实现这个算法?
a是一个n行1列的矩阵,
a=[1,1,1,0,0,0,0,0,0,0,1,1,1,0,0,0,1,0,1.];
将a变为:
a=[1,1,1,0,1,2,3,4,5,6,1,1,1,0,1,2,1,0,1.];

matlab中如何实现这个算法?a是一个n行1列的矩阵,a=[1,1,1,0,0,0,0,0,0,0,1,1,1,0,0,0,1,0,1.];将a变为:a=[1,1,1,0,1,2,3,4,5,6,1,1,1,0,1,2,1,0,1.];
a = [1 1 1 0 0 0 0 0 0 1 1 0 0 0 1 0 0 1 1 1 0];
b = bwlabel(~a);
C = a;
for i = 1 : max(b(:))
C(b==i) = 0:(sum(b==i)-1);
end