Plotting The Amplitude for Fourier Series Coefficients

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

Risposte (1)

Ameer Hamza
Ameer Hamza il 1 Ott 2020
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 Commenti
Salik Mallick
Salik Mallick il 1 Ott 2020
Thank you, but how do I plot the actual function?
Ameer Hamza
Ameer Hamza il 1 Ott 2020
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)

Accedi per commentare.

Categorie

Scopri di più su Discrete Data Plots in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by