How to fix a discontinuity through interpolation

Good morning everyone,
I am trying to find an interpolation method that helps me avoid a discontinuity. In Particular, i made a lookup table periodic (from -180 to 180) using a wrapTo180 function. The plot i obtain is this:
The only problem i have is at 180 (and 180 + 2pi and so on). In this particular point the plot has a discontinuity.
Would it be possible to make the function continuous in C1 interpolating the values that come out of the lookup table? I'd basically like to obtain the same diagram, without the knee.
Thank you in advace for the help.

6 commentaires

If you take the second derivative in that segment, how close is it to constant before the knee and after the knee ?
Thank you for the answer. So, since the discontinuity is in 180, i plotted the trends of the first and the second derivative in [175,185].
It has a jump of about 2. I sincerely do not know if i can consider this close to constant
Suppose you take that segment (including the discontinuity) and try polyfit with degree 3, and try polyfit with degree 4, and use polyval to interpolate back, and in each of the two cases check to see whether the result is sufficiently close to the original data that you would be willing to use it.
Thanks for the help. I have just one question for clarification. The all simulink model has a ramp as input, and a size step of 1. This means that the output signal from the lookup table is 1-D. If i understand correctly, in order to use polyfit i have to have a sample of data and not only 1.
If I understand correctly, you have a lookup table, and you currently have a problem because the table data on the two sides of the wrap has a single-point jump but also the table data on the two sides of the wrap has angles.
On that basis, I proposed a way for you to smooth out the data that you put into your lookup table. You are getting data from somewhere to put into your lookup table, and I am suggesting just fiddling with that data a little once so that every time after that the problem does not occur.
I wonder how many terms in a Fourier series it would take to fit that well...

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Interpolation dans Centre d'aide et File Exchange

Produits

Version

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by