How can I group data points together

조회 수: 3 (최근 30일)
Matthew Suddith
Matthew Suddith 2020년 11월 30일
댓글: Rena Berman 2021년 5월 6일
I need to "bin" data points together into one number. This file has 70,000 lines of data points, in unevenly spaced, often repeating increments. For example, I need to average all the different numbers (2.419, 2.417, 2.405, etc...) with decimals into 2.000.
  댓글 수: 4
Matthew Suddith
Matthew Suddith 2020년 12월 2일
Thank you! I meant to edit it but I completely deleted it and couldnt figure out how to get it back.
Rena Berman
Rena Berman 2021년 5월 6일
(Answers Dev) Restored edit

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

답변 (1개)

Cris LaPierre
Cris LaPierre 2020년 11월 30일
It doesn't sound like you want to average them. For the example you've given, why not just round the numbers down to 2? The functions round, ceil, floor and fix might be of interest to you.
vals = [2.419, 2.417, 2.405];
round(vals)
ans = 1×3
2 2 2
ceil(vals)
ans = 1×3
3 3 3
floor(vals)
ans = 1×3
2 2 2
fix(vals)
ans = 1×3
2 2 2
  댓글 수: 35
Matthew Suddith
Matthew Suddith 2020년 12월 2일
That worked. How could I plot my rounded data and the original data in one plot for a direct comparison, is that doable?
Cris LaPierre
Cris LaPierre 2020년 12월 2일
Ch 9 of MATLAB Onramp.

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

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by