Azzera filtri
Azzera filtri

how to plot the exponential fourier series in matlab?

8 visualizzazioni (ultimi 30 giorni)
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));

Risposta accettata

VBBV
VBBV il 19 Ott 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 Commenti
Daniel Niu
Daniel Niu il 19 Ott 2022
Thank you so much for your explanation! Thank you!
VBBV
VBBV il 19 Ott 2022
Please accept the answer if it solved your problem

Accedi per commentare.

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by