Filter löschen
Filter löschen

특정 인덱스에 해당하는 데이터 연산에 대해 질문드립니다.

2 Ansichten (letzte 30 Tage)
HCLEE
HCLEE am 27 Dez. 2022
Bearbeitet: Varun am 21 Mär. 2023
아래 그림과 같이 첫 번째 'Lot' 열은 상위 항목이고 두 번째 'Ratio' 열은 하위 항목입니다.
그리고 각 항목에 해당하는 'Net' 숫자가 있는 상황에서 동일 항목끼리의 'Net'을 더한 'Sum'이라는 새로운 행렬을 구하고 싶습니다.
문의드린 내용은 최대한 단순화 시킨 예시이고 실제로는 6000 행 이상의 데이터라 단순히 find 함수로 일일이 구할 수 없는 상황임을 알려드립니다.
완전 초보라 for문을 구해서 써야할지 전혀 감이 안오는데 도움 주실 수 있을까요?
엑셀 파일도 첨부하여 올립니다.

Antworten (1)

Varun
Varun am 21 Mär. 2023
Bearbeitet: Varun am 21 Mär. 2023
Hello!
As per my understanding, you want to group the rows of your table using the variables ‘Lot’ and ‘Ratio’ and then, get the sum of the variable ‘Net’. I think a good solution to this would be using the ‘findgroups’ function to group the variables and then, calling ‘splitapply’ to get the sum. The code looks something like this:
G=findgroups(ex.Lot,ex.Ratio)
netsum=splitapply(@sum,ex.Net,G)
However, the rows would have to be sorted when using this, so you can use ‘sortrows’ for this.
You may refer to the following documentation links for:
Hope this helps!

Kategorien

Mehr zu MATLAB 시작하기 finden Sie in Help Center und File Exchange

Tags

Produkte


Version

R2022b

Community Treasure Hunt

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

Start Hunting!