필터 지우기
필터 지우기

How to interpolate arrays for smoothening?

조회 수: 128 (최근 30일)
Ellen
Ellen 2014년 8월 26일
댓글: Ellen 2014년 8월 26일
Hi all,
I'd like to interpolate an array of x-values to apply a spine function to it later (I'd like to smoothen my dataset). However, the x-array is a discontinuous vector, so the general explanation how to interpolate with interp1 does not work for my data. This is the array:
14.1 13.7 12.8 11 9.22 6.18 5.57 5 4.27 3.42 2.57
Does any of you have an idea how I could interpolate this array? Or maybe other ideas how to smoothen it, if not?
Thanks!
  댓글 수: 1
Adam
Adam 2014년 8월 26일
Do you not have a sampling vector to go with that? i.e. the values at which those results were calculated. If you know where your discontinuities are can you not just use interp1 piece-wise between discontinuities?

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

답변 (1개)

Andrew Reibold
Andrew Reibold 2014년 8월 26일
편집: Andrew Reibold 2014년 8월 26일
To interpolate an array, you need the following
X: An array of data, lets call it your independant data.
Y: An array of data corresponding to X. For each value of X there is a value for Y.
X_interpolated: An array of data of NEW X points at positions you want Y interpolated at.
Example:
X = [1 2 3 4 5 6 7]
Y = [10 11.5 14 15 16.5 18 20]
X_interpolated = [1:.5:7]
Y_interpolated = interp1(X,Y,X_interpolated)
Now if you plot
plot(X_interpolated,Y_interpolated)
you will find that points have been interpolated to fill in the gaps of the initial data. Specifically, these points are located at whatever you chose for X_interpolated
If you want to make it curvy or smooth after that, if appropriate, you could use 'smooth' to take a moving line average of the data like this
Y_smooth = smooth(Y_interpolated)
plot(X_interpolated, Y_smooth)
Otherwise I would suggest trying to use something like polyfit for your function... if its a function.
  댓글 수: 1
Ellen
Ellen 2014년 8월 26일
Thanks Andrew for your response. The problem with my data is that it is not really a function, but a set of scatterpoints which do not relate. I've checked a lot, including your suggestion for polyfit, but all of this does not work for my set of data. Thanks anyway though!

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

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by