How to filter two columns of a table in MATLAB, determine the average and count the data in the columns
조회 수: 3 (최근 30일)
이전 댓글 표시
I would like to filter for Vehtype = 650 and their respective Travel Time (Trav). After which, I would like to extract all the filter data and determine the average Travel Time (Trav.) for this vehicle type. I would also like to count the number of vehicles under this vehicle type (Vehtype = 650).
댓글 수: 1
Dyuman Joshi
2023년 3월 23일
What have you tried yet? Please show your code.
And please attach your code using the paperclip button, so it is easy for us to provide suggestions or solutions.
채택된 답변
Cris LaPierre
2023년 3월 23일
편집: Cris LaPierre
2023년 3월 28일
Use groupsummary
If you have shared your data instead of a screenshot, we could test the settings, but you probably want something like this.
mnTbl = groupsummary(Tbl,"Vehtype","mean","Trav")
This will give you the groupcount and mean travel time for each vehicle type. From there, you can extract the info for the specific vehicle type you are interested in. See the Access Data in Tables page for more on how to do that.
추가 답변 (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!