How to make a data set periodic?

11 ビュー (過去 30 日間)
Vinit Nagda
Vinit Nagda 2021 年 12 月 2 日
コメント済み: John D'Errico 2021 年 12 月 2 日
I have a data set that contains radius values for angle theta [0,2pi) and phi [0,pi]. How do I make this data set periodic so that radius value for theta=0 and theta=2pi coincide for a specific angle phi and I get a closed object when I plot it?

回答 (2 件)

John D'Errico
John D'Errico 2021 年 12 月 2 日
編集済み: John D'Errico 2021 年 12 月 2 日
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 件のコメント
Vinit Nagda
Vinit Nagda 2021 年 12 月 2 日
@John D'Errico Thank you for your response.
I have a close surface shown in the figure below (in 2D). The dots are the data points for which I know the values in spherical coordinates. Now using this data points I am trying to reconstruct the closed figure. I do this by interpolating the data points in 4 quadrants (0-pi/2, pi-2-pi.....3pi/2-2pi). However, in doing so the values at theta=0 and theta=2pi do not intersect or coincide and that's why I do not get a closed figure. Hence, my question, how do I make it periodic or rather equate the values at 0 and 2pi to get a closed figure.
I hope I am more clear then the question I posted above?
John D'Errico
John D'Errico 2021 年 12 月 2 日
So linear interpolation is not adequate to make the curve perfect. Why is that a problem? Just connect the ends of the curve, copying the first point to the end.

サインインしてコメントする。


Image Analyst
Image Analyst 2021 年 12 月 2 日
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.

カテゴリ

Help Center および File ExchangeDiscrete Data Plots についてさらに検索

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by