how to plot the exponential fourier series in matlab?

11 ビュー (過去 30 日間)
Daniel Niu
Daniel Niu 2022 年 10 月 19 日
コメント済み: VBBV 2022 年 10 月 19 日
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)
  3 件のコメント
Daniel Niu
Daniel Niu 2022 年 10 月 19 日
Thank you so much for your explanation! Thank you!
VBBV
VBBV 2022 年 10 月 19 日
Please accept the answer if it solved your problem

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMATLAB についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by