Sum data based on buckets/edges (SumIF?)
5 次查看(过去 30 天)
显示 更早的评论
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!
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/786113/image.png)
0 个评论
采纳的回答
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.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Startup and Shutdown 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!