任务一

写出由以下程序形成的信号经周期延拓得到的周期信号的时域表达式(T=2π)(T=2\pi)

1
2
3
t=-2*pi:0.001:2*pi;
y=sawtooth(0.5*t,1);
plot(t,y);

编程计算其指数形式的傅里叶系数(计算至11次谐波);

用MATLAB画出前11次谐波叠加的波形,并指明吉布斯现象出现于何处。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
%原信号波形
t1 = -2*pi:0.001:2*pi;
y1 = sawtooth(0.5*t1,1);
subplot(3,1,1);
plot(t1,y1);

%周期延拓
t2 = -8*pi:0.001:8*pi;
y2 = sawtooth(0.5*mod(t2,4*pi),1);
subplot(3,1,2);
plot(t2,y2);

%谐波叠加
t = -2*pi:0.001:2*pi;
g = zeros(size(t));
f = zeros(size(t));
for n = -11:11
g = 1j/(n*pi);
f = f+g*exp(1j*0.5*t*n);
end
y = sawtooth(0.5*t,1);
subplot(3,1,3);
xlabel('t');
plot(t,y);
hold on;
plot(t,f);
legend('y 原函数','f 谐波叠加波形图');
image-20210509165810258

x = sawtooth(t,xmax) 为锯齿三角波函数,描述周期内-11的线性变化,在xmax*T处达到最大值1而后回落到-1

周期延拓 把一个区间上的函数拓展到整个区间。

很明显可以看出原函数周期T=4πT=4\pi,我不知该如何写出按周期T=2πT=2\pi延拓后得到的函数or2

图三不连续点两侧出现吉布斯现象。

任务二

Write a function called square_wave that computes the sum

k=1nsin[(2k1)t]2k1\displaystyle\sum_{k=1}^{n}{\frac{sin[(2k-1)t]}{2k-1}}

for each of 1001 values oftt uniformly spaced from 0 to4π4\pi inclusive. The input argument is a scalar non-negtive integernn, and the output argument is a row vector of 1001 such sums–one sum for each value oftt. You can test your function by calling it withn=20n=20 or greater and plotting the result and you will see why the function is called “square_wave”.

完成英文部分的实验,读出n=200n=200square_wave函数生成的波形的参数(如幅度、周期等),利用该参数和MATLAB函数square() 画出一致的标准波形。

1
2
3
4
5
6
7
8
9
10
11
12
13
function f = square_wave(n)
n = 200;
t = linspace(0,4*pi,n);
k = 1:n;
for num_t = 1:n
t_temp = t(num_t);
numerator = sin((2*k-1) * t_temp);
denominator = 2*k-1;
result = numerator ./ denominator;
f(num_t) = sum(result);
end

plot(k,f);
image-20210509211001604

如图所示,n=200n=200时,波形近似为幅度A=0.8A=0.8,周期T=100T=100的方波。

1
2
3
4
5
%上接原程序
hold on;
y = 0.8*square(2*pi/100*k);
plot(k,y);
axis([0,200,-1,1]);
image-20210509212456339

任务三

  1. What functionf(t)f(t) has the Fourier series

    n=1sin(nt)n\displaystyle\sum_{n=1}^{\infty}\frac{sin(nt)}{n}

    You can evaluate the sum analytically or numerically. Either way, guess a closed form forf(t)f(t) and then sketch it.

  2. Confirm your conjecture forf(t)f(t) by finding the Fourier series coefficientsfnf_n forf(t)f(t). Compare your result to the expression in the previous part. What happens to the cosione terms?

  3. Define the partial sum

    fN(t)=n=1Nsin(nt)nf_N(t)=\displaystyle\sum_{n=1}^{N}\frac{sin(nt)}{n}

    Plot somefN(t)f_N(t)'s. By what fraction doesfN(t)f_N(t) overshootf(t)f(t) at worst? Does that fraction tend to zero or to a finite value asNN\to\infty ? If it is a finite value, estimate it. (hint: Gibbs phenomenon)

  4. Now define the average of the partial sums:

    FN(t)=f1(t)+f2(t)+f3(t)++fN(t)NF_N(t)=\frac{f_1(t)+f_2(t)+f_3(t)+\cdots+f_N(t)}{N}

    Plot someFN(t)F_N(t)'s. Compare your plots with those offN(t)f_N(t) that you made in the previous part, and qualitatively explain any differences.

1
2
3
4
5
6
7
8
9
10
11
12
13
m=[];
i=1;
for t = -10:0.01:10, s = 0;
for n = 1:1:10000
s = s + sin(n*t)/n;
end
m(i) = s;
i=i+1;
end
t = -10:0.01:10;
plot (t,m);
xlim([-3*pi 3*pi]);
ylim([-2 2]);
image-20210510092941422
1
2
3
4
5
6
7
8
9
10
11
12
13
t = -pi:0.01:pi;
syms n;
w1 = symsum(sin(n*t)/n,n,1,30);
w2 = symsum(sin(n*t)/n,n,1,60);
w3 = symsum(sin(n*t)/n,n,1,90);
S = symsum(sin(n*t)/n,n,1,9999);
plot(t,S);
hold on
plot(t,w1,'r');
hold on
plot(t,w2,'g');
hold on
plot(t,w3,'b');
image-20210510093759166
1
2
3
4
5
6
7
8
9
10
11
t = -3:0.01:3;
syms n
syms y
w1 = symsum(symsum(sin(n*t)/n,n,1,y),y,1,40)/40;
w2 = symsum(symsum(sin(n*t)/n,n,1,y),y,1,80)/80;
w3 = symsum(symsum(sin(n*t)/n,n,1,y),y,1,160)/160;
plot(t,w1,'m');
hold on
plot(t,w2,'b');
hold on
plot(t,w3,'g');
image-20210510102119743