find the maximum value in within a specific range?

2 visualizaciones (últimos 30 días)
Kim Arnold
Kim Arnold el 3 de Mayo de 2023
Comentada: Kim Arnold el 3 de Mayo de 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!

Respuesta aceptada

KSSV
KSSV el 3 de Mayo de 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 comentario
Kim Arnold
Kim Arnold el 3 de Mayo de 2023
Dear KSSV
Thanks for the input, like this I could easily write a for loop. Thank you!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Performance and Memory en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by