Creating new data where each new row is the minimum (of 2nd column) of each 2 rows.
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Hello, I have the following data and I want to create a new set such that for each 2 rows of data, the row is taken with the lowest value in col 2.
i.e. it would begin like this:
1 61 % min of rows 1 & 2
2 57 % min of rows 3 & 4
3 56 % min of rows 5 & 6
4 79 % min of rows 7 & 8
1.00 61.00
2.00 62.00
3.00 60.00
4.00 57.00
5.00 56.00
6.00 60.00
7.00 79.00
8.00 82.00
9.00 55.00
10.00 55.00
11.00 54.00
12.00 53.00
13.00 53.00
14.00 53.00
15.00 62.00
16.00 57.00
17.00 72.00
18.00 58.00
19.00 83.00
20.00 73.00
21.00 102.00
22.00 77.00
23.00 107.00
24.00 111.00
25.00 NaN
26.00 NaN
27.00 NaN
28.00 NaN
28.00 0.20
0 Kommentare
Akzeptierte Antwort
Jason
am 12 Mär. 2025
Bearbeitet: Jason
am 12 Mär. 2025
2 Kommentare
Cris LaPierre
am 12 Mär. 2025
Only reshape an even number of rows.
y = [61 62 60 57 56 60 79 82 55 55 54 53 53 53 62 57 72 58 83 73 102 77 107 111 NaN NaN NaN NaN 0.2];
r = 2*floor(length(y)/2);
B = reshape(y(1:r),2,[]) % Each column is a pair of row data
C=min(B)
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Logical 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!