Re: simple array manipulation without loops?
- From: "D Stobbe" <dstobbe101@xxxxxxxxx>
- Date: Mon, 4 Aug 2008 17:47:01 +0000 (UTC)
Why is Desired the desired ordering, and not Desired2 =[1; 3; 9; 2; 4]?
Since 3 appears first in A, shouldn't it be before theelements of B in the
Desired array?
Am I reading too much into "maintain the ordering"?
The output being [1; 9; 2; 3; 4] instead of [1; 3; 9; 2; 4]
is merely an artifact of the order the arguments are passed
to the "unique" function (ie for repeated values the last
occurance has it's indicie passed)
A = [1; 3; 9];
B = [2; 3; 4];
temp=[A; B];**
[r,m,n]=unique(temp);
Desired = temp(sort(m))
EQUALS[1; 9; 2; 3; 4]
Where as
A = [1; 3; 9];
B = [2; 3; 4];
temp=[B; A];**
[r,m,n]=unique(temp);
Desired = temp(sort(m))
EQUALS[2; 4; 1; 3; 9]
******
For my purpose, i must have at least one array maintain its
original order, however, i can achieve this by just making
that array the second argument in the stacking line temp=
[X,X].
.
- Follow-Ups:
- Re: simple array manipulation without loops?
- From: Bruno Luong
- Re: simple array manipulation without loops?
- References:
- simple array manipulation without loops?
- From: D Stobbe
- Re: simple array manipulation without loops?
- From: Steven Lord
- simple array manipulation without loops?
- Prev by Date: Re: simple array manipulation without loops?
- Next by Date: Re: convert bit streams to byte streams
- Previous by thread: Re: simple array manipulation without loops?
- Next by thread: Re: simple array manipulation without loops?
- Index(es):
Relevant Pages
|