how do you make an interpolation such that it interpolates the value betwee the first and the last array entry?
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I have a position array from 0 to 100 (with corresponding values in a separate array) and I have calculated some query points, the first one being at -0.15. Of course this is outside the range of which interpolation is possible, however, the problem I am solving is strictly periodic. This means that extrapolating below zero is the same as interpolating between the the first and the last entry of the value-array (between zero and 100). How can modify my program such that I can accommodate this periodicity?
1 Kommentar
John D'Errico
am 10 Jun. 2017
Please don't add answers when you make a comment, just to respond to an answer.
Antworten (1)
Les Beckham
am 9 Jun. 2017
IF you are saying that the 'position = 100' value is the same as the 'position = 0' value then you can just do a modulo 100 on the input position value before you do the interpolation. For your example:
>> mod(-0.15, 100)
ans =
99.8500
So, interpolating with the mod result would give you the same answer as if you interpolated with 99.85.
If my assumption is not correct (e.g., the 'position = 100' value is actually the same as the unspecified 'position = -1' value) you would need to tweak this approach. Maybe just append a copy of the 'position = 0' value as 'position = 101' and modulo with 101. You will have to add a 101 entry to your position vector (the x for interp1) as well.
I hope that this helps.
1 Kommentar
John D'Errico
am 10 Jun. 2017
Moved to a comment from Ulla:
"Thanks so much for your answer.
It would solve my problem if it was as simple as that. The problem is the interpolation calculation is in a loop, so I calculate different query points every loop. sometimes, it's negative in the first input, other times it's not, sometimes it's beyond 100 in the last time step, other times it is not.
Is there a way to make sure that anything below zero or above 100 is interpreted as just the pattern repeating?"
Siehe auch
Kategorien
Mehr zu Interpolation finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!