find the maximum value in within a specific range?

7 Ansichten (letzte 30 Tage)
Kim Arnold
Kim Arnold am 3 Mai 2023
Kommentiert: Kim Arnold am 3 Mai 2023
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!

Akzeptierte Antwort

KSSV
KSSV am 3 Mai 2023
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))
  1 Kommentar
Kim Arnold
Kim Arnold am 3 Mai 2023
Dear KSSV
Thanks for the input, like this I could easily write a for loop. Thank you!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Graphics Object Programming 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!

Translated by