How can I find the index of the maximum Value in a given subintervall in the normal array
2 views (last 30 days)
Show older comments
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 Comments
Accepted Answer
More Answers (0)
See Also
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!