Creating new data where each new row is the minimum (of 2nd column) of each 2 rows.
조회 수: 1 (최근 30일)
이전 댓글 표시
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
채택된 답변
Jason
2025년 3월 12일
편집: Jason
2025년 3월 12일
댓글 수: 2
Cris LaPierre
2025년 3월 12일
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)
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!