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 件のコメント
Karan Gill
Karan Gill 2017 年 10 月 16 日
Please format your question and code.

サインインしてコメントする。

回答 (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 Center および File ExchangeFourier Analysis and Filtering についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by