Finding Max difference between column vectors
6 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Bradley Ross
am 6 Okt. 2017
Bearbeitet: Cedric
am 6 Okt. 2017
I have a set of data in an array (about 3450x8) and I need to find the maximum difference between columns 5 and 6, is there an easy way to do this in Matlab? Also is there a way for it to then tell me which row that the maximum difference is in? Many thanks in Advance
0 Kommentare
Akzeptierte Antwort
Cedric
am 6 Okt. 2017
Bearbeitet: Cedric
am 6 Okt. 2017
If it is in absolute value:
[M, I] = max( abs( A(:,5) - A(:,6) ))
and otherwise remove the call to ABS.
PS: if you want to find all rows where the max occurs (if there can be multiple), you will have to do it as follows:
absDiff = abs( A(:,5) - A(:,6) ) ;
M = max( absDiff ) ;
I = find( absDiff == M ) ;
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Multidimensional Arrays finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!