z*****n 发帖数: 7639 | 1 ^*I have two vectors:
a = [1 1 1 2 3 4 4];
b = [0 0 0 1 0 2 2];
how to compress a and b so that unique a and their corresponding b
values are held? I am trying to solve it without a loop. |
e***y 发帖数: 4307 | 2 i think this is what you need using the function unique
[anew, ii, jj] = unique(a);
bnew = b(ii); |
z*****n 发帖数: 7639 | 3 thanks a lot!
This code is so beautiful.
【在 e***y 的大作中提到】 : i think this is what you need using the function unique : [anew, ii, jj] = unique(a); : bnew = b(ii);
|
z1 发帖数: 389 | 4 你真是土的像鳖一样。
【在 z*****n 的大作中提到】 : thanks a lot! : This code is so beautiful.
|
y*******w 发帖数: 5917 | 5 骂别人鳖的人恐怕自己就是王8。术业有专攻,
【在 z1 的大作中提到】 : 你真是土的像鳖一样。
|