Interpolate consecutive values of a single array
Show older comments
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 Comments
Sargondjani
on 16 Nov 2022
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
on 17 Nov 2022
Accepted Answer
More Answers (1)
Luca Castrogiovanni
on 17 Nov 2022
0 votes
Categories
Find more on Matrices and Arrays in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!