필터 지우기
필터 지우기

Sum data based on buckets/edges (SumIF?)

조회 수: 5 (최근 30일)
Ryan Hinrichsen
Ryan Hinrichsen 2021년 11월 1일
댓글: Ryan Hinrichsen 2021년 11월 1일
I have a data array containing two columns:
Damage value - corresponding to how much damage occurs at that data point
# cycles - how many cycles occur during the data point
I would like to sum the # of cycles for a given set of bins/edges (not always equally spaced). In Excel this would be a very simple SumIF, albeit across a number of cells to populate a table. I can write the same logic in Matlab, but it requires a loop to check each bin/edge set. Is there an elegant single-line solution, similar to histcounts, that will allow me to pass a series of bins/edges and sum the cells that meet that criteria?
In the attached image, the example input data is on the left and the output data I desire is on the right with the thick border around the cells.
Thanks in advance for your assistance!

채택된 답변

Steven Lord
Steven Lord 2021년 11월 1일
See the groupsummary function. The "Specify Group Bins" example on its documentation page looks very similar to what you want to do.
  댓글 수: 1
Ryan Hinrichsen
Ryan Hinrichsen 2021년 11월 1일
Fantastic answer, I have never heard of this function before. Greatly appreciate the help!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by