Find Index of Max Value in One Matrix and find value of that index in another
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Caitlin Bemis
am 17 Sep. 2022
Beantwortet: Davide Masiello
am 17 Sep. 2022
I have time series data that corresponds with eachother. I have two matrices of the same length, that have force and length of a muscle. I want to find the index of the max value of force and use that index to find the value (which is not always the max) of the length. Any example is fine with random data- I can figure out how to apply it to my own later.
(In R it would be data$Length[which.max[data$Force])... I don't know that equivalent in Matlab though).
0 Kommentare
Akzeptierte Antwort
Davide Masiello
am 17 Sep. 2022
You can do it this way
force = rand(1,10);
length = rand(1,10);
[max_force,idx] = max(force);
max_length = length(idx);
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!