join - Octave Conditional Merging of matrices -
i have searched octave function facilitates conditional merging of matrices haven't 1 far. goal using vectors without looping. here example of trying do.
a= [1 1 2 2 3 1 5 2]; b= [1 9 2 10]; i c as
c= [1 1 9 2 2 10 3 1 9 5 2 10]; is there function takes a, b , list of column(s) join on , produce c?
you can use second output of ismember find occurrences of second column of a in first column of b , use grab specific entries second column of b construct c.
[~, inds] = ismember(a(:,2), b(:,1)); c = [a, b(inds,2)]; %// 1 1 9 %// 2 2 10 %// 3 1 9 %// 5 2 10
Comments
Post a Comment