serie fourier using matlab

3 次查看(过去 30 天)
nour yousfi
nour yousfi 2017-10-15
编辑: nour yousfi 2017-10-16
hi; I want a fourier transform of a piecewise function using matlab . The function is defined as follows:
0.6+t/0.3*pi when 0 <t < 0.12*pi
1 when 0.12*pi <t < 1.08*pi
4.6-t/0.3*pi when 1.08*pi <t < 1.2*pi
0.6 when 1.2*pi <t <2*pi
any help will be appreciated
I tried to do that but I didn't found a good result
Matlab file: clear all syms t n T1=2*pi;
I1 = int((0.6+(t/0.3*pi)), t,0,0.12*pi); I2 = int(1, t,0.12*pi,1.08*pi); I3 = int((4.6-(t/0.3*pi)), t,1.08*pi,1.2*pi); I4 = int(0.6, t,1.2*pi,2*pi);
a0 = (1/T1)*(I1 + I2 + I3+I4); fourierSum = 0;
II1 = int((0.6+(t./0.3*pi))*cos((2*n*pi*t)/T1), t,0,0.12*pi); II2 = int((1)*cos((2*n*pi*t)/T1), t,0.12*pi,1.08*pi); II3 = int((4.6-(t./0.3*pi))*cos((2*n*pi*t)/T1), t,1.08*pi,1.2*pi); II4 = int((0.6)*cos((2*n*pi*t)/T1), t,1.2*pi,2*pi); III1 = int((0.6+(t./0.3*pi))*sin((2*n*pi*t)/T1), t,0,0.12*pi); III2 = int(sin((2*n*pi*t)/T1), t,0.12*pi,1.08*pi); III3 = int((4.6-(t./0.3*pi))*sin((2*n*pi*t)/T1), t,1.08*pi,1.2*pi); III4 = int((0.6)*sin((2*n*pi*t)/T1), t,1.2*pi,2*pi);
for k = 1:40 an = subs(II1 + II2 + II3+II4,n,k); bn = subs(III1 +III2+III3+III4,n,k); term = an*cos((2*k*pi*t)/T1); termm = bn*sin((2*k*pi*t)/T1); fourierSum = fourierSum+term+termm; fourierSum=(2/T1)*fourierSum; end
ezplot(vpa(a0+fourierSum,6), [0 10])

回答(1 个)

nour yousfi
nour yousfi 2017-10-15
编辑:nour yousfi 2017-10-15
the result must be as it shown in the following picture

类别

Help CenterFile Exchange 中查找有关 Fourier Analysis and Filtering 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by