What's the Best Way to Symbolically Define the Periodic Extension of a Finite Duration Signal?

18 views (last 30 days)
Suppose I have a finite duration signal:
syms s(t)
s(t) = triangularPulse(0,1,1.5,t);
fplot(s(t))
Now I want to define the periodic extension of this signal from t = -inf to inf. I can extend it over a finite duration. For example, with a period P
syms n P real
assumeAlso(n,'integer');
assumeAlso(P,'positive');
sp(t,P) = symsum(s(t - n*P),n,-5,5)
sp(t, P) = 
fplot(sp(t,3),[-20 20])
And I can evaluate it as well:
sp(1,3)
ans = 
1
But extending to infinity doesn't seem to work so well
sp(t,P) = symsum(s(t - n*P),n,-inf,inf)
sp(t, P) = 
% fplot(sp(t,3),[-20 20]) % code took too long to run
sp(1,3)
ans = 
Is there a way to define a periodic extension that can be evaluated, integrated, etc.? I feel like there should be a way to do it using rem or mod or something similar ....

Answers (1)

Paul
Paul on 23 Oct 2021
The Symbolic Math Toolbox function mod() changed behavior in 2020b so that (it appears) that such a function can now be easily defined. Link to doc page. I think I was experimenting with mod() in 2019a and that's why it wasn't working for me.
syms s(t)
s(t) = triangularPulse(0,1,1.5,t);
fplot(s(t))
syms P
s_p(t,P) = s(mod(t,P))
s_p(t, P) = 
fplot(s_p(t,2))
  2 Comments
Martin
Martin on 23 Feb 2022
Edited: Martin on 23 Feb 2022
@Paul How could I calculate the fourier transform of the signals I created with the mod function? Is there a way to do this with a specified intervall for showing the frequency spectrum of the infinite periodic signal?
For example, if I try this:
syms s(t)
s(t) = rectangularPulse(-1,1,t);
syms p
sp(t,p) = s(mod(t,p));
T = 3;
nexttile(1);
fplot(sp(t,T));
abs_ft = abs(fourier(sp(t,T)));
nexttile(2);
fplot(abs_ft);
I get the following error:
The following error was reported evaluating the function in FunctionLine update: Unable to convert expression containing remaining symbolic function calls into double array. Argument must be expression that evaluates to number.
Do you know a way to handle this?
Paul
Paul on 23 Feb 2022
Edited: Paul on 23 Feb 2022
As far as I know, fourier() doesn't compute a closed form expression of the Fourier transform of a general, periodic function, though it can for specific cases like complex exponentials.
The Fourier transform of a periodic function is an impulse train of Dirac delta functions at integer multiples of the function's fundamental frequency, scaled by the coefficients of its complex Fourier series and another scaling factor depending on the Fourier transform convention being used. I think you'll have to write your own code to compute those coefficients.
Even if fourier() could compute the FT of a general periodic function, the fplot() would be uninteresting because fplot() ignores delta functions.

Sign in to comment.

Products


Release

R2021b

Community Treasure Hunt

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

Start Hunting!