Max/Min Values in a table
28 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I'm trying to find the max and min values of a table, and the times that each max and min occurred, what function/syntax would I use to find these values? table =
24×4 table
t wsp1 wsp2 wsp3
__ ____ ____ ____
1 7.8 6.9 6.7
2 7.5 6.8 6.4
3 8.5 8.1 8
4 8.4 6.8 6.5
5 11.1 7.2 6.9
6 14.5 11.7 11.5
7 22.6 16 15.6
8 34.9 22.6 20
9 30 20.5 18.5
10 29.5 18.1 18
11 21.3 15.6 14.5
12 20.5 13.9 13.4
13 18.4 13.8 13
14 15.6 9.3 8.9
15 14 9.2 8.5
16 13.9 9.1 8.8
17 13 8 7.4
18 11.8 7 6.3
19 12.4 7.1 6.8
20 13.4 5.8 5.4
21 5.6 5.7 4.7
22 6.7 4.2 3.6
23 6.4 4.5 3.2
24 5.9 4.4 3.8
0 comentarios
Respuestas (2)
Walter Roberson
el 18 de Feb. de 2018
[min_vals, min_idx] = min(YourTable{:,2:4});
min_times = YourTable.t(min_idx);
Now min_vals(1) is the minimum wsp1 and that occurred at time min_times(1)
Steven Lord
el 15 de Abr. de 2025
As of release R2023a, you can directly call min on a table or timetable array as long as all the variables are of a data type that supports the calculation.
T = array2table(magic(5))
[minValues, minLocations] = min(T)
resultInVariableVar2 = T{minLocations.Var2, "Var2"}
0 comentarios
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!