serie fourier using matlab
Show older comments
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 Comment
Karan Gill
on 16 Oct 2017
Please format your question and code.
Answers (1)
nour yousfi
on 15 Oct 2017
Edited: nour yousfi
on 15 Oct 2017
Categories
Find more on Fourier Analysis and Filtering 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!
