Interpolate consecutive values of a single array
이전 댓글 표시
Hi guys!
I have two datasets whose arrays have not the same length. The first contains Beta values and it counts 100 values; the second are temperature data and it contains 7985 values. What I would like to do is a linear interpolation between two consecutive data values from beta, in order to get the same length of temperature array.
So, if temperature values are 7985, I would require 79.85 linear interpolated beta elements from beta1 to beta2, then 79.85 linear interpolated elements from beta2 to beta3, and so on ...
In the end I would get a 7985 beta array I will be able to scatterplot Vs. 7985 temperature array data.
Is it possible to easly create such a script/function? I am trying using linspace function, but I cannot make it consecutive value after value.
Thanks in advance for your patience and help :)
댓글 수: 2
Sargondjani
2022년 11월 16일
Have a look at griddedInterpolant.
x = 1:100;
intBeta = griddedInterpolant(x,Beta,'linear')
Now you can linearly interpolate between beta values: intBeta(1.5) should give you the Beta value between observation 1 and 2.
So next you would need to construct a vector where you retrieve the interpolated beta values. there's examples in the function description.
Luca Castrogiovanni
2022년 11월 17일
채택된 답변
추가 답변 (1개)
카테고리
도움말 센터 및 File Exchange에서 Matrices and Arrays에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
