Fourier Series for a Periodic Function

20 ビュー (過去 30 日間)
Salik Mallick
Salik Mallick 2020 年 9 月 29 日
編集済み: KALYAN ACHARJYA 2020 年 9 月 30 日
Why is the graph not complete?
%% Problem 1_Example_17.2
display('Problem 1_Example_17.1')
ao=1/4;
an=[1/[(n^2)*(pi^2)]]*((1-(-1)^n));
N = 100000;
Wo = pi;
t = -1:.001:11;
f = zeros(1,length(t));
for n = 1:2:N
bn = (-1)^n+1;
f = f + an*cos(Wo*n*t) + bn*sin(Wo*n*t);
end
% Plotting and plot formatting is done here
plot(t,f)
axis([-1 11 -1.1 1.1])
title(['Fourier Series Representation w/ ' num2str(N) ' Terms'],'FontSize',16)
xlabel('Time')
ylabel('Function Value')

採用された回答

KALYAN ACHARJYA
KALYAN ACHARJYA 2020 年 9 月 30 日
編集済み: KALYAN ACHARJYA 2020 年 9 月 30 日
display('Problem 1_Example_17.1')
ao=1/4;
N = 100000;
Wo = pi;
t = -1:.001:11;
f = zeros(1,length(t));
n =linspace(1,2,length(t));
bn = (-1).^n+1;
an=1./((n.^2).*(pi^2)).*((1-(-1).^n));
f = f + an.*cos(Wo*n.*t) + bn.*sin(Wo*n.*t);
% Plotting and plot formatting is done here
plot(t,f);
grid on;
title(['Fourier Series Representation w/ ' num2str(N) ' Terms'],'FontSize',16)
xlabel('Time');
ylabel('Function Value');
axis tight;
Is this?

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeFourier Analysis and Filtering についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by