# How to make a data set periodic?

8 views (last 30 days)

Show older comments

##### 0 Comments

### Answers (2)

John D'Errico
on 2 Dec 2021

Edited: John D'Errico
on 2 Dec 2021

How do you MAKE it periodic? It is either periodic or it is is not. Is the value at 0 the same as that at 2*pi? If not, then what will you do? :)

Ok, you might try an intervention. Sit down with your data, and have a heart to heart talk with it. Hey, it might help. Or there are groups to help your data deal with its aperiodicity. APDA (APeriodic Data Anonymous) is such a group with a good track record. They have a 2*pi step program. Remember that relapse into aperiodicity can be a problem with such data.

Seriously, if your data is not periodic, then I would first ask why it is not. Is the difference merely noise in your data? It seems you have several simple choices.

First: Ignore it, just connecting the ends. This effectively treats the relation as periodic, but discontinuous at the joint. For example the periodic extension of the line segment y=x, from the interval [0,1) is validly periodic. That is, the function mod(x,1) is exactly that. Periodic, but discontinuous.

fplot(@(x) mod(x,1),[-5,5])

grid on

So perfectly periodic. Not continuous, but who cares?

Next, you could try to tweak the data. This is fraught with problems in how you will do it, if you hope to do so with any degree of intelligence and do so automatically. While I think it is what you are asking (and I could probably even figure out a way to do so, given enough time and a look at your data, I won't try.) So good luck in your quest.

Next, you could model your entire data set, using a tool that embodies periodicity in it. For example, my SLM toolbox allows you to estimate a function that smoothly represents your data as well as is possible, yet is also periodic as a constraint. You can find SLM on the file exchange. This may be the simplest solution, but it will require you to download and learn to use a tool like SLM. It is free, as long as you have the optimization toolbox.

Finally, you could model your data using a Fourier series. This works because a Fourier series is composed of only terms that are themselves periodic. So as long as n is an integer, then sin(n*x) is ALWAYS a periodic function of x on the interval [0,2*pi). the same applies to cos(n*x). So any superposition as a sum of such terms (plus a constant) is also implicitly periodic. Of course, if your data is not itself periodic, then you may see ringing or Gibbs phenomena appear in your model at the joint. This is a common problem at such a point of singularity in your data, a reflection of the singularity when you try to force a continuous model across such a point.

Without seeing your data, any of the above suggestions could be correct, and I have no idea which nor would I guess, since I cannot see your data. The crystal ball is foggy today.

##### 2 Comments

John D'Errico
on 2 Dec 2021

Image Analyst
on 2 Dec 2021

You ask how can "I get a closed object when I plot it? "

Have you tried tacking on the first point to the end?

x = [x, x(1)];

y = [y, y(1)];

z = [z, z(1)];

plot3(x, y, z, 'b.-', 'LineWidth', 2, 'MarkerSize', 20);

Now the curve should be closed and not open.

##### 0 Comments

### See Also

### Community Treasure Hunt

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

Start Hunting!