how to plot the exponential fourier series in matlab?

40 次查看(过去 30 天)
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));

采纳的回答

VBBV
VBBV 2022-10-19
% (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)

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 MATLAB 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by