Plotting The Amplitude for Fourier Series Coefficients

3 次查看(过去 30 天)
%% Problem 1
display('Problem 1')
syms n t
Wo = pi;
T = 2;
n = 1:10;
a0=(1/T)*(int(t,t,0,1))
an= (2/T)*(int(t*cos(n*Wo*t),0,1))
bn=(2/T)*(int(t*sin(n*Wo*t),0,1))

回答(1 个)

Ameer Hamza
Ameer Hamza 2020-10-1
Something like this
syms n t
Wo = pi;
T = 2;
n = 1:10;
a0 = (1/T)*int(t,t,0,1);
an = (2/T)*int(t*cos(n*Wo*t),0,1);
bn = (2/T)*int(t*sin(n*Wo*t),0,1);
subplot(2,1,1)
title('an');
stem(0:10, [a0 an])
subplot(2,1,2)
title('bn');
stem(1:10, bn)
  2 个评论
Ameer Hamza
Ameer Hamza 2020-10-1
Following plot actual function
syms n t
Wo = pi;
T = 2;
n = 1:10;
a0 = (1/T)*int(t,t,0,1);
an = (2/T)*int(t*cos(n*Wo*t),0,1);
bn = (2/T)*int(t*sin(n*Wo*t),0,1);
t = linspace(0, 1);
x = zeros(size(t));
x(:) = a0;
for i = 1:numel(an)
x = x + an(i)*cos(Wo*i*t) + bn(i)*sin(Wo*i*t);
end
plot(t, x)

请先登录,再进行评论。

类别

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

标签

Community Treasure Hunt

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

Start Hunting!

Translated by