Inspired after seeing a cool Youtube video of Fourier series... How do I implement a Fourier series for an irregular non periodic curve?
10 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Firstly, this is the Youtube video What is a Fourier Series? (Explained by drawing circles) - Smarter Every Day 205 from channel SmarterEveryDay.
I could understand the model for creating the square wave. I think it is easy too because we have a function to implement the code.
But, How can one implement a model for a curve which is non periodic which does not have a function?
For example, At the end of the video, it shows a fourier series for a curve like in the picture below, He is definetly using 2 Dimensional fourier transform.
So, I took time trying to implement the Idea and this is how far I have come.
>>>>>>I took the picture of my profile and traced the edges into 3 ranges and concatenated them into a vector. So, when I create a functon, It can start to trace like shown in the picture below.
>>>>>>I thought 2D Fourier transform would be difficult, so I went for 1D first. I tried for implementing the idea for the 3 ranges separately. I used the curve fitting toolbox to approximate the curves.
>>>>> I used 8 order fourier terms to get the fits as shown on the picture above. 8 was the maximum I could get.
>>>>> For Range 3 the fit was perfect. but for complicated shapes like Range 1, the maximum fit of 8 terms wasn't sufficient.
>>>>> From the picture from youtube, you can see that he goes for more than 40 terms. Then he gets more perfect fit for orders 200 or so..
Finally, how can I get to higher orders inspite of curve fitting tool allows only 8?
Is there any other way that I can approach this problem?
If i could slove this, I have ideas to implement this algorithm scientifically for various other purposes.
Kindly help me regarding this problem.
3 comentarios
Rik
el 28 de Dic. de 2018
I'll try to get you going, but the code below shows what I mean by splitting it into two functions
x=Ranges_Concatenated(:,2);
y=Ranges_Concatenated(:,1);
t=1:numel(x);
figure(1),clf(1)
plot(t,x,'b','DisplayName','x-coordinate')
hold on
plot(t,y,'r','DisplayName','y-coordinate')
legend
I usually use fminsearch, but that tends to have trouble to find a good solution if your initial guess is too far off. Of course you could use fft directly to solve this, but that would be cheating. ;)
Respuesta aceptada
Rik
el 28 de Dic. de 2018
First I misunderstood it a bit: I just let Matlab figure out the desired wavelenght as well, but that turns out to be quite tricky, and it doesn't work well either. The plots shown below were made with the attached code. The two left plots are only for the x component, but I'm sure the y will show something similar.
4 comentarios
Rik
el 28 de Dic. de 2018
You are very welcome.
I wanted to take a shot at it when I saw the video come out, but I never came round to it, so thank you for giving me the final push to try it out (and handing me a usable trace to work with).
The next part should be fun as well: how to animate the circles? If you take a shot at that as well, let me know in a comment here so it shows up in my activity feed.
Más respuestas (0)
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!