find the maximum value in within a specific range?

2 次查看(过去 30 天)
Let's say I have a range of numbers within 50-61 (i.e. 50.36, 50.94, 51.45. 51.86, 51.93 etc.). Each of those numbers have an assigned intensity value ranging from 1-1000. I would now like to find for each number the maximum assigned intensity value (i.e. 50-51, 51-52, 52-53 etc.).
Lets take the example below for numbers 50-52:
number intensity
50.36 2
50.94 500
51.45 40
51.86 253
51.93 290
52.16 960
52.39 15
I would like to know the ID of rows which show the maximum value within for each integer/whole number (i.e. for 50 the max value would be 500 which is ID2, for 51 it is 290 and therefore ID5 etc.). What would be the easiest way to get those IDs? A smart way to use the max function within each number area. Thank you very much for your help!

采纳的回答

KSSV
KSSV 2023-5-3
A = [50.36 2
50.94 500
51.45 40
51.86 253
51.93 290
52.16 960
52.39 15];
% max with 50
A1 = A(fix(A(:,1))==50,:) ;
[val,idx] = max(A1(:,2))

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Performance and Memory 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by