0

I have a column of values which outputs like the following:

d =

 1
 1
 3
 1
 1
 2
 1

I am looking to combine the integers that are > 0 to the following:

e =

 1
 2
 3
 4
 5
 6
 7
 8
 9
10

So for instance the first value is 1 so it would only be assigned to one value in e (the first). I am looking to have an unique identifier for each separate value to output this:

e =

 1   1
 2   2
 3   3
 4   3
 5   3
 6   4
 7   5
 8   6
 9   6
10   7
4

1 回答 1

0

这是一个使用bsxfun

e = [e 1+sum(bsxfun(@gt, 1:sum(d),cumsum(d))).'];
于 2013-09-26T15:12:31.543 回答