> > Prime Mover <eple...@hotmail.com> wrote in message <0685b44e-9fbb-4ac0-a8=
> a4-0e2900ce0...@u18g2000pro.googlegroups.com>...
> >
> > > Having two matrices a and b like in the example below:
< snip ...
> So,
> a correct example of the task would be:
[quoted text clipped - 20 lines]
> ----------
> Thanks for the interest and sorry again for the confusion.
Something like this, perhaps:
uab = union(a(:,1:2),b(:,1:2),'rows')
tfa = ismember(uab,a(:,1:2),'rows')
tfb = ismember(uab,b(:,1:2),'rows')
uab(:,3:4) = NaN
uab(tfa,3) = a(:,3)
uab(tfb,4) = b(:,3)
hth
Jos
Prime Mover - 31 Oct 2008 19:40 GMT
> > > Prime Mover <eple...@hotmail.com> wrote in message <0685b44e-9fbb-4ac0-a8=
> > a4-0e2900ce0...@u18g2000pro.googlegroups.com>...
[quoted text clipped - 39 lines]
>
> - Mostrar texto entre aspas -
Yes, I was looking for a way in that you don't need to lookup in the
original matrices again to find the desired indices, so as to reduce
processing time. I have matrices with thousands of rows.
Thank you.
Bruno Luong - 31 Oct 2008 21:05 GMT
% Data
a =[ 3 3 -5;
4 5 -6;
4 4 -9;
4 5 -3 ]
b =[ 4 4 -2;
4 5 -4;
8 7 -15;
9 0 -1 ]
% Engine
acolor=a(:,[1 2]);
bcolor=b(:,[1 2]);
[trast ib] = unique([acolor; bcolor], 'rows');
[trast ia] = unique([bcolor; acolor], 'rows');
ib=ib-size(a,1);
ia=ia-size(b,1);
c=nan(length(ia),4);
t=ia>0; c(t,[1 2 3])=a(ia(t),:);
t=ib>0; c(t,[1 2 4])=b(ib(t),:);
% Check
c
% Bruno