From: Gue Phisan on
Hi All,
I am trying to convert this matrix:
A = [0 1 1 0 1;1 1 1 1 0;1 0 1 1 0]
to:
B = [1 2 2 3 4;2 2 2 2 3;2 5 2 2 3]

The value of matrix A is 0 or 1. I need to make variable clusters for the same values and change the values to the index cluster but don't know how to do it.

Thanks,
GP
From: Steven Lord on

"Gue Phisan" <dataparman(a)gmail.com> wrote in message
news:hm36je$etl$1(a)fred.mathworks.com...
> Hi All,
> I am trying to convert this matrix:
> A = [0 1 1 0 1;1 1 1 1 0;1 0 1 1 0]
> to:
> B = [1 2 2 3 4;2 2 2 2 3;2 5 2 2 3]
>
> The value of matrix A is 0 or 1. I need to make variable clusters for the
> same values and change the values to the index cluster but don't know how
> to do it.

Use BWLABEL, first on A then on 1-A. Combine the two results by filling in
the zeros in one of them with the nonzeros (appropriately scaled) from the
other.

--
Steve Lord
slord(a)mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ