Ismembertol command calculating average between two matched rows
Ältere Kommentare anzeigen
Hi everyone! I have a doubt about the ismembertol command, I'm trying to compare two matrices using this command.
A = [2.5 4.4 ; 3.6 8.9];
B = [2.8 4.6 3 ; 4.9 7.1 5 ; 3.5 8.7 2 ; 3.4 8.8 6 ; 4.9 12.5 4];
[ia,ib] = ismembertol(A,B(:,1:2), 0.2, 'ByRows',true);
a = [A(ia,:) B(ia,3)]
I'd like to obtain 3.6 8.9 4 as a result (4 is the average between the third column of the of the third and fourth rows of B) because there are two rows that match, but it returns:
a =
2.5000 4.4000 3.0000
3.6000 8.9000 5.0000
Thank you!
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Set Operations finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!