Fourier series fit to a periodic function with multiple frequencies

36 views (last 30 days)
Hi everyone,
I want to fit a Fourier series to a square wave functoin with two frequencies and varying amplitude. I have attached the graph for more clarification.
I can estimate the simple square wave with Fourier series. But the problem arises when I modify the amplitude of the wave with some other frequency. In the figure below, the square wave period is the same as blue function. But at some points the amplitudes are changing and the period of this part is different than the main period. Fourier series provides the average as DC part and cannot model this.
I would be grateful if you share with me your ideas on how to solve the problem.
Behrang Hoseini
Behrang Hoseini on 22 Aug 2022
Edited: Behrang Hoseini on 22 Aug 2022
Hi Paul,
Thank you for your answer.
Well, actually this is a wave with some defect. Let's say the there is a square wave that you can easily estimate its Fourier Series counterpart. We can say that there are two waves but am not sure if can be expressed as a summation.
To generate the function, I have written the following code. it may clarify more.
I have defined a periodic window to multiply with the main wave but the problem is that the final function becomes discontinuous.
fs = 5e05;%[Hz]
f_sun = 27.4286;% [Hz]
T = 1/f_sun;
n = 4*fix(T*fs);% number of steps TWO SUN revolutions
Fm = 600;% [Hz]
tspan = (0:n-1)/fs;% Solution time [s]
t = tspan;
kl = 3e08; %[N/m]
ku = 5e08;
m_is = 1.45;
m_ir = 1.64;
t_sun = 0.0156;
k_mean = ku*(m_is-1) + kl*(2-m_is);
k_t1 = 1/pi*(sin(2*pi*1*m_is)*cos(1*2*pi*Fm*t)+(1-cos(2*pi*1*m_is))*sin(1*2*pi*Fm*t))+...
k_t = (ku-kl)*k_t1 + k_mean;
i = 1 ;% number of the planet gear, first i = 0
Tm = 1/Fm ;
Tp = round(3*t_sun,2);% [s] Period of the wave based on sun rotation
t1 = 0.0 + i*t_sun;
t2 = (m_is-1)*Tm + i*t_sun;% [s] mesh period of first double tooth pair
t3 = m_is*Tm + i*t_sun;% [s] mesh period of single tooth pair + second double tooth pair
y = ( mod(t,Tp)>t1& round(mod(t,Tp),4)<t2)*0.95 + (round(mod(t,Tp),4)>t2 & round(mod(t,Tp),4)<t3)*0.84;
y1 = ~y;
w = y+y1;
k_t = k_t .* w;% Multiply with window W
if w <= 0
disp('window function is zero')
pause (5)
xlabel('t [s]');ylabel('k_m [N/m]')
xlim([0 0.05])
ylim([2 6]*1e08)

Sign in to comment.

Answers (2)

Star Strider
Star Strider on 12 Aug 2022
Adding a second function will change the baseline, for example —
t = linspace(0, 10, 1000);
s = sum((1./[1;3;5]).*sin([1;3;5]*2*pi*t*0.5)) + 0.1*cos(2*pi*t*0.1);
It might be appropriate to use some sort of stepwise funciton rather than a continuous function, depending on the result you want.

Sign in to comment.

Benjamin Thompson
Benjamin Thompson on 12 Aug 2022
Try looking over the documentation of the fft in MATLAB, along with the examples included there. If you have more specific questions and can post some of your work that you have a question about then post that to this board or add it to this questions.
Behrang Hoseini
Behrang Hoseini on 23 Aug 2022
Thank you Benjamin,
Well you are right. My aim is to estimate the square wave by any method. I have used 15 harmonics to estimate the wave. However, it does not work for the case of varying amplitude.

Sign in to comment.


Find more on Descriptive Statistics in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by