how to find fourier coefficients an and bn?
7 views (last 30 days)
Show older comments
hi guys, i want to know if someone can help me with this code, the thing is that i want to calculate the coefficients of a fourier transform, i made this code with an example that my teacher of university give me, but the thing is that the result is wrong an is very weird because with other examples the program works good, but especially with this example the program give me wrong results for an and bn. can someone help me to know what's wrong? pleasseee. and thanks.
this is the example:
and this is the code:
close all
clc
syms t n
pi=3.1416;
A = [-pi 0 pi]; %intervalos
f = [-1 2]; %funciones
f = sym(f);
T = max(A)-min(A);
wo = 2*pi/(T);
Ao = 0;
for i=1:length(f)
Ao = Ao +int(f(i), A(i), A(i+1));
end
Ao =(2*Ao/T)
An = 0;
syms n t pi
for i=1:length(f)
An = An + int(f(i)*cos(n*wo*t), A(i), A(i+1))
end
Bn = 0;
for i=1:length(f)
Bn = Bn + int(f(i)*sin(n*wo*t), A(i), A(i+1));
end
Bn = simple(2*Bn/T)
0 Comments
Answers (0)
See Also
Categories
Find more on String Parsing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!