This forum has been archived. All content is frozen. Please use KDE Discuss instead.

find a value according to intersect result (two matrix)

Tags: None
(comma "," separated)
imonz
Registered Member
Posts
3
Karma
0
I am currently porting some matlab code to C++ and trying to use the Eigen library.I want to know how to transfer this block of code into c++? It's purpose is to find a value which is in A(:,3) according to B(:,1:2) whose two data is equal to A(:,1:2).
row= 1:n
[~,ia,ib] = intersect(A(:,1:2),B(:,1:2),'rows');
B(ib,row) = A(ia,3);

for example:
A<<1,2,3
4,5,6
7,8,9
B<<7,8,
4,5,
the result is
B = 7,8,9
4,5,6
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
I'm afraid there is no helper for that ask. You can compare rows as A.row(i)==B.row(j) and copy rows in a similar way, but you will have to do the rest by yourself.


Bookmarks



Who is online

Registered users: bartoloni, Bing [Bot], Evergrowing, Google [Bot], ourcraft