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!
