MATLAB Answers

Reduce data points from 200 to 108

조회 수: 95(최근 30일)
Maxwell Barton
Maxwell Barton 21 Nov 2019
댓글: Daniel M 21 Nov 2019
I have a data series with 200 data points and I need to compress this information to 108 data points. I don't think I can use a moving average filter as the window wouldn't be an integer so is there a way in MATLAB to do this?

  댓글 수: 0

로그인 to comment.

채택된 답변

Star Strider
Star Strider 21 Nov 2019
I have no idea what your data are or what you want to do with them, other than reduce the number of them.
Interpolating them to a shorter independent variable vector may be an option. See if the interp1 function can do what you want. The linspace function can be helpful in providing the new independent variable vector.

  댓글 수: 3

Star Strider
Star Strider 21 Nov 2019
To use the Signal Processing Toolbox resample function, use the integers you have (200 108) for the ‘p’ and ‘q’ arguments.
With respect to interpolation, if your current data are ‘x’ and ‘y’ for the independent and dependent variables respectively, use linspace:
xnew = linspace(min(x), max(x), 108);
ynew = interp1(x, y, xnew);
Make appropriate changes to work with your data.
Maxwell Barton
Maxwell Barton 21 Nov 2019
Thanks resampling is what I was looking for!
Star Strider
Star Strider 21 Nov 2019
As always, my pleasure!

로그인 to comment.

추가 답변(1개)

Daniel M
Daniel M 21 Nov 2019
편집: Daniel M 21 Nov 2019
Do you want to:
  1. truncate your signal?
  2. downsample or resample
  3. interpolate
  4. something else?
Truncate example:
t = 1:200;
x = rand(1,200);
x2 = x(1:108);

  댓글 수: 2

Maxwell Barton
Maxwell Barton 21 Nov 2019
Truncation wouldn't work unfortunately. How would I downsample with a non integer rate (200/108 = 1.8519)?
And how would interpolation work; it wouldn't work as below.
time_1= 1:200
time_2 = 1:108
interp1(time,data_1,time_2)
Daniel M
Daniel M 21 Nov 2019
That's what resampling function is for. Star Strider has responded under his answer.

로그인 to comment.

이 질문에 답변하려면 로그인을(를) 수행하십시오.

태그

제품


릴리스

R2018a

Translated by