Effacer les filtres
Effacer les filtres

how to plot the exponential fourier series in matlab?

6 vues (au cours des 30 derniers jours)
Daniel Niu
Daniel Niu le 19 Oct 2022
Commenté : VBBV le 19 Oct 2022
I expand a periodic function exp(-t) with T=3.
then sum the series to compare with the original function. However, I think the oscillation
is too large. Where is the problem?
Your help would be highly appreciated.
Best regards.
% (a)plot x(t) over a time interval (0,3)
clear;clc
t = 0:0.01:3; % total simulation time
x = exp(-t);
plot(t,x,'r','LineWidth',2)
a=zeros(1,61);
for K=-30:30
G=@(t)exp(-(t)).*exp(-1i*K*2*pi/3.*t);
a(K+31)=1/3*quad(G,0,3);
end
x30 = 0.*t;
for j = 1:30
x30 = x30 + 2*real(a(j+31)*exp(1i*(j)*pi.*t/1.5));
end
x30=x30++a(31);
hold on
plot(t, x30,'b','LineWidth',2)
% plot(t,x1,'b','LineWidth',2)
% plot(t,abs(x2),'b','LineWidth',3)
%K=-30:30
%stem(K,abs(a));

Réponse acceptée

VBBV
VBBV le 19 Oct 2022
% (a)plot x(t) over a time interval (0,3)
clear;clc
t = 0:0.01:3; % total simulation time
x = exp(-t);
plot(t,x,'r','LineWidth',2)
a=zeros(1,61);
for K=-30:30
G=@(t)exp(-(t)).*exp(-1i*K*2*pi/3.*t);
a(K+31)=1/3*integral(G,0,3);
end
x30 = 0.*t;
for j = 1:30
x30 = x30 + 2*real(a(j+31)*exp(1i*(j)*pi.*t/1.5));
end
x30=x30++a(31);
hold on
plot(t, x30,'b','LineWidth',2)
  3 commentaires
Daniel Niu
Daniel Niu le 19 Oct 2022
Thank you so much for your explanation! Thank you!
VBBV
VBBV le 19 Oct 2022
Please accept the answer if it solved your problem

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by