How can I find the index of the maximum Value in a given subintervall in the normal array
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Kaihua Zhang
am 7 Apr. 2020
Kommentiert: Kaihua Zhang
am 17 Mai 2020
Hi community,
first time asking a question here. I am currently dealing with task involving this problem:
For simplification, lets say, I have two corresponding arrays:
Current_array = [0 1 2 3 4 5];
Voltage_array = [1 2 3 4 5 6];
I want to find the index of the maximum Value in the current_array, but only in the regime, where the corresponding Voltage_array is smaller than 2:
[~,index] = max ( (Current_array (Voltage_array > 2) ) );
My output index would be 4, since the largest value of my subarray (Current_array (Voltage_array > 2) ) = [3 4 5 6] is at position 4.
But what I really want is to find the index of that maximum value in my Current_array, which would be index = 6.
Is there an elegent way to solve this?
0 Kommentare
Akzeptierte Antwort
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!