0% found this document useful (0 votes)
22 views16 pages

Fourier Analysis Using MATLAB

The document discusses Fourier analysis using MATLAB, focusing on the implementation of trigonometric Fourier series for signals with and without time shifts. It provides code examples that demonstrate how changes in pulse width and time shifts affect the signals and their Fourier coefficients. The analysis includes various configurations of the input parameters, illustrating the resulting phase responses and signal characteristics.

Uploaded by

serget1
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views16 pages

Fourier Analysis Using MATLAB

The document discusses Fourier analysis using MATLAB, focusing on the implementation of trigonometric Fourier series for signals with and without time shifts. It provides code examples that demonstrate how changes in pulse width and time shifts affect the signals and their Fourier coefficients. The analysis includes various configurations of the input parameters, illustrating the resulting phase responses and signal characteristics.

Uploaded by

serget1
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Fourier Analysis Using MATLAB

Dr. James Kang


Professor
ECE Department
Cal Poly Pomona

1. Exercise18p9b.m

Trigonometric Fourier series.

f(t) is a signal without time shift.


g(t) is a signal with time shift of td.
g(t) = f(t – td)

1.1 Default

The code without any changes assumes that input f(t) shown below is applied to an RC circuit
shown below.

0.5
f(t)

0
-2 -1.5 -1 -0.5 0 0.5 1 1.5 2
t 10
-3

+
1k
f (t)
C y (t)
0.1uF
-

A=1;T0=1e-3;tau=0.5e-3;N=10;td=0.0e-3;
R=1000;C=0.1e-6;M1=2;M2=1000;Th=1e-12;M=N;

Since td is zero, f(t) and g(t) are identical. We get same answers twice:
f(t): a, b, c, theta, thetad
g(t): ga, gb, gc, gtheta, gthetad
f0 =
1000
w0 =
6.2832e+03
d=
0.5000

1
a0 =
0.5000
a=
0.5000 0.6366 0.0000 -0.2122 -0.0000 0.1273 0.0000 -0.0909 -0.0000 0.0707 0.0000
b=
0 0 0 0 0 0 0 0 0 0 0
c=
0.5000 0.6366 0.0000 0.2122 0.0000 0.1273 0.0000 0.0909 0.0000 0.0707 0.0000
theta =
0 0 0 3.1416 0 0 0 3.1416 0 0 0
theta =
0 0 0 3.1416 0 0 0 3.1416 0 0 0
thetad =
0 0 0 180 0 0 0 180 0 0 0
ga =
0.5000 0.6366 0.0000 -0.2122 -0.0000 0.1273 0.0000 -0.0909 -0.0000 0.0707 0.0000
gb =
0 0 0 0 0 0 0 0 0 0 0
gc =
0.5000 0.6366 0.0000 0.2122 0.0000 0.1273 0.0000 0.0909 0.0000 0.0707 0.0000
gtheta =
0 0 0 3.1416 0 0 0 3.1416 0 0 0
gtheta =
0 0 0 3.1416 0 0 0 3.1416 0 0 0
gthetad =
0 0 0 180 0 0 0 180 0 0 0

1.2 If the first line is commented out and the second line is uncommented, we have

% A=1;T0=1e-3;tau=0.5e-3;N=10;td=0.0e-3;
A=1;T0=1e-3;tau=0.25e-3;N=10;td=0.0e-3;

Rest of the code is unchanged. The only change is the pulse width τ is reduced from 0.5 ms to
0.25 ms. f(t) and g(t) are identical.

0.5
f(t)

0
-2 -1.5 -1 -0.5 0 0.5 1 1.5 2
t 10
-3

f0 =
1000
w0 =
6.2832e+03
d=
0.2500
a0 =
0.2500
a=
0.2500 0.4502 0.3183 0.1501 0.0000 -0.0900 -0.1061 -0.0643 -0.0000 0.0500 0.0637
b=
0 0 0 0 0 0 0 0 0 0 0
c=
0.2500 0.4502 0.3183 0.1501 0.0000 0.0900 0.1061 0.0643 0.0000 0.0500 0.0637
theta =
0 0 0 0 0 3.1416 3.1416 3.1416 0 0 0

2
theta =
0 0 0 0 0 3.1416 3.1416 3.1416 0 0 0
thetad =
0 0 0 0 0 180 180 180 0 0 0
ga =
0.2500 0.4502 0.3183 0.1501 0.0000 -0.0900 -0.1061 -0.0643 -0.0000 0.0500 0.0637
gb =
0 0 0 0 0 0 0 0 0 0 0
gc =
0.2500 0.4502 0.3183 0.1501 0.0000 0.0900 0.1061 0.0643 0.0000 0.0500 0.0637
gtheta =
0 0 0 0 0 3.1416 3.1416 3.1416 0 0 0
gtheta =
0 0 0 0 0 3.1416 3.1416 3.1416 0 0 0
gthetad =
0 0 0 0 0 180 180 180 0 0 0

1.3 If the second line is commented out and the third line is uncommented, we have

% A=1;T0=1e-3;tau=0.5e-3;N=10;td=0.0e-3;
% A=1;T0=1e-3;tau=0.25e-3;N=10;td=0.0e-3;
A=1;T0=1e-3;tau=0.25e-3;N=10;td=0.5e-3;

There is a time shift of 0.5ms. The pulse train is shifted by 0.5ms to the right.
g(t) = f(t – 0.5ms). The phase response of f(t) and g(t) are different.

0.5
g(t)

0
-2 -1.5 -1 -0.5 0 0.5 1 1.5 2
t 10
-3

f0 =
1000
w0 =
6.2832e+03
d=
0.2500
a0 =
0.2500
a=
0.2500 0.4502 0.3183 0.1501 0.0000 -0.0900 -0.1061 -0.0643 -0.0000 0.0500 0.0637
b=
0 0 0 0 0 0 0 0 0 0 0
c=
0.2500 0.4502 0.3183 0.1501 0.0000 0.0900 0.1061 0.0643 0.0000 0.0500 0.0637
theta =
0 0 0 0 0 3.1416 3.1416 3.1416 0 0 0
theta =
0 0 0 0 0 3.1416 3.1416 3.1416 0 0 0
thetad =
0 0 0 0 0 180 180 180 0 0 0
ga =
0.2500 -0.4502 0.3183 -0.1501 0.0000 0.0900 -0.1061 0.0643 -0.0000 -0.0500 0.0637
gb =
1.0e-15 *
0 0.0551 -0.0780 0.0551 -0.0000 -0.2151 0.0780 -0.0551 0.0000 0.0551 -0.3041
gc =

3
0.2500 0.4502 0.3183 0.1501 0.0000 0.0900 0.1061 0.0643 0.0000 0.0500 0.0637
gtheta =
0 -3.1416 -6.2832 -9.4248 0 -12.5664 -15.7080 -18.8496 0 -28.2743 -31.4159
gtheta =
0 -3.1416 0 -3.1416 0 0.0000 -3.1416 0 0 -3.1416 0.0000
gthetad =
0 -180.0000 0 -180.0000 0 0.0000 -180.0000 0 0 -180.0000 0.0000

1.4 If the third line is commented out and the fourth line is uncommented, we have

% A=1;T0=1e-3;tau=0.5e-3;N=10;td=0.0e-3;
% A=1;T0=1e-3;tau=0.25e-3;N=10;td=0.0e-3;
% A=1;T0=1e-3;tau=0.25e-3;N=10;td=0.5e-3;
A=1;T0=1e-3;tau=0.25e-3;N=10;td=-0.25e-3;

There is a time shift of -0.25ms. The pulse train is shifted by 0.25ms to the left.
g(t) = f(t + 0.25ms). The phase response of f(t) and g(t) are different.

0.5
g(t)

0
-2 -1.5 -1 -0.5 0 0.5 1 1.5 2
t 10
-3

f0 =
1000
w0 =
6.2832e+03
d=
0.2500
a0 =
0.2500
a=
0.2500 0.4502 0.3183 0.1501 0.0000 -0.0900 -0.1061 -0.0643 -0.0000 0.0500 0.0637
b=
0 0 0 0 0 0 0 0 0 0 0
c=
0.2500 0.4502 0.3183 0.1501 0.0000 0.0900 0.1061 0.0643 0.0000 0.0500 0.0637
theta =
0 0 0 0 0 3.1416 3.1416 3.1416 0 0 0
theta =
0 0 0 0 0 3.1416 3.1416 3.1416 0 0 0
thetad =
0 0 0 0 0 180 180 180 0 0 0
ga =
0.2500 0.0000 -0.3183 -0.0000 0.0000 -0.0000 0.1061 0.0000 -0.0000 0.0000 -0.0637
gb =
0 -0.4502 -0.0000 0.1501 0.0000 0.0900 0.0000 -0.0643 -0.0000 -0.0500 -0.0000
gc =
0.2500 0.4502 0.3183 0.1501 0.0000 0.0900 0.1061 0.0643 0.0000 0.0500 0.0637
gtheta =
0 1.5708 3.1416 4.7124 0 10.9956 12.5664 14.1372 0 14.1372 15.7080
gtheta =
0 1.5708 3.1416 -1.5708 0 -1.5708 0 1.5708 0 1.5708 3.1416
gthetad =
0 90.0000 180.0000 -90.0000 0 -90.0000 0 90.0000 0 90.0000 180.0000

4
1.5 If the fourth line is commented out and the fourth line is uncommented, we have

% A=1;T0=1e-3;tau=0.5e-3;N=10;td=0.0e-3;
% A=1;T0=1e-3;tau=0.25e-3;N=10;td=0.0e-3;
% A=1;T0=1e-3;tau=0.25e-3;N=10;td=0.5e-3;
% A=1;T0=1e-3;tau=0.25e-3;N=10;td=-0.25e-3;
A=1;T0=1e-3;tau=0.25e-3;N=10;td=0.125e-3;

There is a time shift of 0.125ms. The pulse train is shifted by 0.125ms to the right.
g(t) = f(t - 0.125ms). The phase response of f(t) and g(t) are different.

0.5
g(t)

0
-2 -1.5 -1 -0.5 0 0.5 1 1.5 2
t 10
-3

f0 =
1000
w0 =
6.2832e+03
d=
0.2500
a0 =
0.2500
a=
0.2500 0.4502 0.3183 0.1501 0.0000 -0.0900 -0.1061 -0.0643 -0.0000 0.0500 0.0637
b=
0 0 0 0 0 0 0 0 0 0 0
c=
0.2500 0.4502 0.3183 0.1501 0.0000 0.0900 0.1061 0.0643 0.0000 0.0500 0.0637
theta =
0 0 0 0 0 3.1416 3.1416 3.1416 0 0 0
theta =
0 0 0 0 0 3.1416 3.1416 3.1416 0 0 0
thetad =
0 0 0 0 0 180 180 180 0 0 0
ga =
0.2500 0.3183 0.0000 -0.1061 -0.0000 0.0637 0.0000 -0.0455 -0.0000 0.0354 0.0000
gb =
0 0.3183 0.3183 0.1061 0.0000 0.0637 0.1061 0.0455 0.0000 0.0354 0.0637
gc =
0.2500 0.4502 0.3183 0.1501 0.0000 0.0900 0.1061 0.0643 0.0000 0.0500 0.0637
gtheta =
0 -0.7854 -1.5708 -2.3562 0 -0.7854 -1.5708 -2.3562 0 -7.0686 -7.8540
gtheta =
0 -0.7854 -1.5708 -2.3562 0 -0.7854 -1.5708 -2.3562 0 -0.7854 -1.5708
gthetad =
0 -45.0000 -90.0000 -135.0000 0 -45.0000 -90.0000 -135.0000 0 -45.0000 -90.0000

1.6 We can change the input signal to triangular pulse train by uncommenting lines with
%triangular. Here are changes:

A=1;T0=1e-3;tau=0.5e-3;N=10;td=0.0e-3;
% A=1;T0=1e-3;tau=0.25e-3;N=10;td=0.0e-3;

5
% A=1;T0=1e-3;tau=0.25e-3;N=10;td=0.5e-3;
% A=1;T0=1e-3;tau=0.25e-3;N=10;td=-0.25e-3;
% % A=1;T0=1e-3;tau=0.25e-3;N=10;td=0.125e-3;
R=1000;C=0.1e-6;M1=2;M2=1000;Th=1e-12;M=N; %RC,
% R=35;L=28e-3;C=0.1e-6;M1=2;M2=1000;Th=1e-10;M=N; %RLC,
f0=1/T0
w0=2*pi/T0
d=tau/T0 %rectangular
% a0=A*tau/T0 %rectangular
a0=A/2 %triangular, sawtooth
% a0=0 %average of f(t) = 0
n1=1:N;
n=0:N;
f1=f0*n;
% aa=2*A*d*sinc(n1*d); %rectangular
aa=A*sinc(n1/2).^2; %triangular
% aa=zeros(1,N) %sawtooth
a=[a0,aa]
ba=zeros(1,N); %rectangular, triangular

% f0a=A*0.5*(1+square(2*pi*(t1+d/2*T0)/T0,100*d));
f0a=0.5*(1+sawtooth(2*pi*(t1+T0/2)/T0,0.5)); %triangular

% g0=A*0.5*(1+square(2*pi*(t1-td+d/2*T0)/T0,100*d));
% g0=0.5*(1+square(2*pi*(t1+0*T0)/T0,100*d));
g0=0.5*(1+sawtooth(2*pi*(t1-td+T0/2)/T0,0.5)); %triangular

0.5
g(t)

0
-2 -1.5 -1 -0.5 0 0.5 1 1.5 2
t 10
-3

Since there is no delay, g(t) = f(t).

f0 =
1000
w0 =
6.2832e+03
d=
0.5000
a0 =
0.5000
a=
0.5000 0.4053 0.0000 0.0450 0.0000 0.0162 0.0000 0.0083 0.0000 0.0050 0.0000
b=
0 0 0 0 0 0 0 0 0 0 0
c=
0.5000 0.4053 0.0000 0.0450 0.0000 0.0162 0.0000 0.0083 0.0000 0.0050 0.0000
theta =
0 0 0 0 0 0 0 0 0 0 0
theta =
0 0 0 0 0 0 0 0 0 0 0
thetad =
0 0 0 0 0 0 0 0 0 0 0
ga =

6
0.5000 0.4053 0.0000 0.0450 0.0000 0.0162 0.0000 0.0083 0.0000 0.0050 0.0000
gb =
0 0 0 0 0 0 0 0 0 0 0
gc =
0.5000 0.4053 0.0000 0.0450 0.0000 0.0162 0.0000 0.0083 0.0000 0.0050 0.0000
gtheta =
0 0 0 0 0 0 0 0 0 0 0
gtheta =
0 0 0 0 0 0 0 0 0 0 0
gthetad =
0 0 0 0 0 0 0 0 0 0 0

1.7 Change the time delay to 0.25ms.


g(t) = f(t – 0.25ms)
line 4:
A=1;T0=1e-3;tau=0.5e-3;N=10;td=0.25e-3;

Since there is a time delay, the phase response of f(t) and g(t) are different.

0.5
g(t)

0
-2 -1.5 -1 -0.5 0 0.5 1 1.5 2
t 10
-3

f0 =
1000
w0 =
6.2832e+03
d=
0.5000
a0 =
0.5000
a=
0.5000 0.4053 0.0000 0.0450 0.0000 0.0162 0.0000 0.0083 0.0000 0.0050 0.0000
b=
0 0 0 0 0 0 0 0 0 0 0
c=
0.5000 0.4053 0.0000 0.0450 0.0000 0.0162 0.0000 0.0083 0.0000 0.0050 0.0000
theta =
0 0 0 0 0 0 0 0 0 0 0
theta =
0 0 0 0 0 0 0 0 0 0 0
thetad =
0 0 0 0 0 0 0 0 0 0 0
ga =
0.5000 0.0000 -0.0000 -0.0000 0.0000 0.0000 -0.0000 -0.0000 0.0000 0.0000 -0.0000
gb =
0 0.4053 0.0000 -0.0450 -0.0000 0.0162 0.0000 -0.0083 -0.0000 0.0050 0.0000
gc =
0.5000 0.4053 0.0000 0.0450 0.0000 0.0162 0.0000 0.0083 0.0000 0.0050 0.0000
gtheta =
0 -1.5708 0 -4.7124 0 -7.8540 0 -10.9956 0 -14.1372 0
gtheta =
0 -1.5708 0 1.5708 0 -1.5708 0 1.5708 0 -1.5708 0
gthetad =
0 -90.0000 0 90.0000 0 -90.0000 0 90.0000 0 -90.0000 0

7
1.8 We can change the input signal to sawtooth pulse train by uncommenting lines with
%sawtooth. No time delay. g(t) = f(t). Here are changes:

A=1;T0=1e-3;tau=0.5e-3;N=10;td=0.0e-3;
% A=1;T0=1e-3;tau=0.25e-3;N=10;td=0.0e-3;
% A=1;T0=1e-3;tau=0.25e-3;N=10;td=0.5e-3;
% A=1;T0=1e-3;tau=0.25e-3;N=10;td=-0.25e-3;
% % A=1;T0=1e-3;tau=0.25e-3;N=10;td=0.125e-3;
R=1000;C=0.1e-6;M1=2;M2=1000;Th=1e-12;M=N; %RC,
% R=35;L=28e-3;C=0.1e-6;M1=2;M2=1000;Th=1e-10;M=N; %RLC,
f0=1/T0
w0=2*pi/T0
d=tau/T0 %rectangular
% a0=A*tau/T0 %rectangular
a0=A/2 %triangular, sawtooth
% a0=0 %average of f(t) = 0
n1=1:N;
n=0:N;
f1=f0*n;
% aa=2*A*d*sinc(n1*d); %rectangular
% aa=A*sinc(n1/2).^2; %triangular
aa=zeros(1,N) %sawtooth
a=[a0,aa]
% ba=zeros(1,N); %rectangular, triangular
ba=-A./(pi*n1); %sawtooth

% f0a=A*0.5*(1+square(2*pi*(t1+d/2*T0)/T0,100*d));
% f0a=0.5*(1+sawtooth(2*pi*(t1+T0/2)/T0,0.5)); %triangular
f0a=0.5*(1+sawtooth(2*pi*(t1+0*T0)/T0,1)); %Sawtooth

% g0=A*0.5*(1+square(2*pi*(t1-td+d/2*T0)/T0,100*d));
% g0=0.5*(1+square(2*pi*(t1+0*T0)/T0,100*d));
% g0=0.5*(1+sawtooth(2*pi*(t1-td+T0/2)/T0,0.5)); %triangular
g0=0.5*(1+sawtooth(2*pi*(t1-td*T0)/T0,1)); %Sawtooth

0.5
g(t)

0
-2 -1.5 -1 -0.5 0 0.5 1 1.5 2
t 10
-3

f0 =
1000
w0 =
6.2832e+03
d=
0.5000
a0 =
0.5000
aa =
0 0 0 0 0 0 0 0 0 0
a=
0.5000 0 0 0 0 0 0 0 0 0 0

8
b=
0 -0.3183 -0.1592 -0.1061 -0.0796 -0.0637 -0.0531 -0.0455 -0.0398 -0.0354 -0.0318
c=
0.5000 0.3183 0.1592 0.1061 0.0796 0.0637 0.0531 0.0455 0.0398 0.0354 0.0318
theta =
0 1.5708 1.5708 1.5708 1.5708 1.5708 1.5708 1.5708 1.5708 1.5708 1.5708
theta =
0 1.5708 1.5708 1.5708 1.5708 1.5708 1.5708 1.5708 1.5708 1.5708 1.5708
thetad =
0 90 90 90 90 90 90 90 90 90 90
ga =
0.5000 0 0 0 0 0 0 0 0 0 0
gb =
0 -0.3183 -0.1592 -0.1061 -0.0796 -0.0637 -0.0531 -0.0455 -0.0398 -0.0354 -0.0318
gc =
0.5000 0.3183 0.1592 0.1061 0.0796 0.0637 0.0531 0.0455 0.0398 0.0354 0.0318
gtheta =
0 1.5708 1.5708 1.5708 1.5708 1.5708 1.5708 1.5708 1.5708 1.5708 1.5708
gtheta =
0 1.5708 1.5708 1.5708 1.5708 1.5708 1.5708 1.5708 1.5708 1.5708 1.5708
gthetad =
0 90 90 90 90 90 90 90 90 90 90

1.9 Change the time delay to 0.25ms.


g(t) = f(t – 0.25ms)
line 4:
A=1;T0=1e-3;tau=0.5e-3;N=10;td=0.25e-3;

Since there is a time delay, the phase response of f(t) and g(t) are different.

0.5
g(t)

0
-2 -1.5 -1 -0.5 0 0.5 1 1.5 2
t 10
-3

f0 =
1000
w0 =
6.2832e+03
d=
0.5000
a0 =
0.5000
aa =
0 0 0 0 0 0 0 0 0 0
a=
0.5000 0 0 0 0 0 0 0 0 0 0
b=
0 -0.3183 -0.1592 -0.1061 -0.0796 -0.0637 -0.0531 -0.0455 -0.0398 -0.0354 -0.0318
c=
0.5000 0.3183 0.1592 0.1061 0.0796 0.0637 0.0531 0.0455 0.0398 0.0354 0.0318
theta =
0 1.5708 1.5708 1.5708 1.5708 1.5708 1.5708 1.5708 1.5708 1.5708 1.5708
theta =
0 1.5708 1.5708 1.5708 1.5708 1.5708 1.5708 1.5708 1.5708 1.5708 1.5708
thetad =
0 90 90 90 90 90 90 90 90 90 90
ga =

9
0.5000 0.3183 0.0000 -0.1061 -0.0000 0.0637 0.0000 -0.0455 -0.0000 0.0354 0.0000
gb =
0 -0.0000 0.1592 0.0000 -0.0796 -0.0000 0.0531 0.0000 -0.0398 -0.0000 0.0318
gc =
0.5000 0.3183 0.1592 0.1061 0.0796 0.0637 0.0531 0.0455 0.0398 0.0354 0.0318
gtheta =
0 0 -1.5708 -3.1416 -4.7124 -6.2832 -7.8540 -9.4248 -10.9956 -12.5664 -14.1372
gtheta =
0 0 -1.5708 -3.1416 1.5708 0.0000 -1.5708 -3.1416 1.5708 0 -1.5708
gthetad =
0 0 -90.0000 -180.0000 90.0000 0.0000 -90.0000 -180.0000 90.0000 0 -90.0000

1.10. Return back to rectangular pulse train with duty cycle 0.5 and td = 0. Change the circuit to
CR circuit shown below. R = 1 kΩ, C = 0.1 µF.

0.5
g(t)

0
-2 -1.5 -1 -0.5 0 0.5 1 1.5 2
t 10
-3

g(t) R
y (t)

Change the transfer function to CR HPF.

% H=(1/(R*C))./(1j*n*w0+(1/(R*C))) %TF (one-sided) H(nw0) RC LPF


H=(1j*n*w0)./(1j*n*w0+(1/(R*C))) %CR HPF

Change the settings for figure(11):

figure(11)
plot(t1,y,'LineWidth',2);grid;
hold on;
plot(t1,g0,'r-');xlabel('t');ylabel('y^\wedge(t)');
hold off;
title(['Approx of y(t) with dc + up to ',num2str(M),'th Harmonic']);
set(gca,'XTick',-M1*T0:T0/2:M1*T0)
set(gca,'XTickLabel',-M1*T0:T0/2:M1*T0)
% set(gca,'YTick',-0.2*A:0.2*A:1.2*A)
% set(gca,'YTickLabel',-0.2*A:0.2*A:1.2*A)
set(gca,'YTick',-1.2*A:0.2*A:1.2*A)
set(gca,'YTickLabel',-1.2*A:0.2*A:1.2*A)
% axis([-M1*T0,M1*T0,-0.2*A,1.2*A]);
% axis([-M1*T0,M1*T0,-0.2*A,1.2*A]);
axis([-M1*T0,M1*T0,-1.2*A,1.2*A]);

10
Return back to original set up.

Approx of y(t) with dc + up to 10th Harmonic


1.2

0.8

0.6

0.4

0.2
y (t)

-0.2

-0.4

-0.6

-0.8

-1

-1.2
-0.002 -0.0015 -0.001 -0.0005 0 0.0005 0.001 0.0015 0.002
t

f0 =
1000
w0 =
6.2832e+03
d=
0.5000
a0 =
0.5000
a=
0.5000 0.6366 0.0000 -0.2122 -0.0000 0.1273 0.0000 -0.0909 -0.0000 0.0707 0.0000
b=
0 0 0 0 0 0 0 0 0 0 0
c=
0.5000 0.6366 0.0000 0.2122 0.0000 0.1273 0.0000 0.0909 0.0000 0.0707 0.0000
theta =
0 0 0 3.1416 0 0 0 3.1416 0 0 0
theta =
0 0 0 3.1416 0 0 0 3.1416 0 0 0
thetad =
0 0 0 180 0 0 0 180 0 0 0
ga =
0.5000 0.6366 0.0000 -0.2122 -0.0000 0.1273 0.0000 -0.0909 -0.0000 0.0707 0.0000
gb =
0 0 0 0 0 0 0 0 0 0 0
gc =
0.5000 0.6366 0.0000 0.2122 0.0000 0.1273 0.0000 0.0909 0.0000 0.0707 0.0000
gtheta =
0 0 0 3.1416 0 0 0 3.1416 0 0 0
gtheta =

11
0 0 0 3.1416 0 0 0 3.1416 0 0 0
gthetad =
0 0 0 180 0 0 0 180 0 0 0
H=
Columns 1 through 7
0.0000 + 0.0000i 0.2830 + 0.4505i 0.6123 + 0.4872i 0.7804 + 0.4140i 0.8633 + 0.3435i 0.9080 + 0.2890i 0.9343 + 0.2478i
Columns 8 through 11
0.9508 + 0.2162i 0.9619 + 0.1914i 0.9697 + 0.1715i 0.9753 + 0.1552i
Hmag =
0 0.5320 0.7825 0.8834 0.9292 0.9529 0.9666 0.9751 0.9808 0.9847 0.9876
Hphase =
0 1.0098 0.6722 0.4878 0.3787 0.3082 0.2593 0.2236 0.1964 0.1750 0.1578
Hphased =
0 57.8581 38.5119 27.9467 21.6970 17.6568 14.8561 12.8092 11.2517 10.0284 9.0431
yc =
0 0.3387 0.0000 0.1875 0.0000 0.1213 0.0000 0.0887 0.0000 0.0697 0.0000
yp =
0 1.0098 0 3.6294 0 0.3082 0 3.3652 0 0.1750 0
ypd =
0 57.8581 0 207.9467 0 17.6568 0 192.8092 0 10.0284 0

2. Exercise18p9c.m

Exponential Fourier series.

2.1 Default

The code without any changes assumes that input f(t) shown below is applied to an RC circuit
shown below.

0.5
f(t)

0
-2 -1.5 -1 -0.5 0 0.5 1 1.5 2
t 10
-3

There is no g(t). Time shifting is included in f(t).


R

+
1k
f (t)
C y (t)
0.1uF
-

A=1;T0=1e-3;tau=0.5e-3;N=10;Th=1e-12;M1=2;M2=1000;td=0.0e-3;
R=1000;C=0.1e-6;

12
Approximation of f(t) with DC + up to 10th Harmonic

f (t) 1

0.5

-2 -1.5 -1 -0.5 0 0.5 1 1.5 2


-3
t 10

0.5

0.4

0.3
|F n |

0.2

0.1

0
-10 -9 -8 -7 -6 -5 -4 -3 -2 -1 0 1 2 3 4 5 6 7 8 9 10

f (kHz)
180

90
(deg)

0
n
F

-90

-180
-10 -9 -8 -7 -6 -5 -4 -3 -2 -1 0 1 2 3 4 5 6 7 8 9 10

f (kHz)

Approximation of y(t) with DC + up to 10th Harmonic

1
(t)

0.5
y

-2 -1.5 -1 -0.5 0 0.5 1 1.5 2


-3
t 10

13
0.5

0.4

0.3
|Y n |

0.2

0.1

0
-10 -9 -8 -7 -6 -5 -4 -3 -2 -1 0 1 2 3 4 5 6 7 8 9 10

f (kHz)
270

180

90
(deg)

0
n

-90
Y

-180

-270
-10 -9 -8 -7 -6 -5 -4 -3 -2 -1 0 1 2 3 4 5 6 7 8 9 10

f (kHz)

2.2 Change tau to 0.25ms and shift f(t) by 0.125ms.

A=1;T0=1e-3;tau=0.25e-3;N=10;Th=1e-10;M1=2;M2=1000;td=0.125e-3;

Approximation of f(t) with DC + up to 10th Harmonic

1
f (t)

0.5

-2 -1.5 -1 -0.5 0 0.5 1 1.5 2


-3
t 10

180

90
(deg)

0
n
F

-90

-180
-10 -9 -8 -7 -6 -5 -4 -3 -2 -1 0 1 2 3 4 5 6 7 8 9 10

f (kHz)

2.3 Change input to triangular pulse train:

A=1;T0=1e-3;tau=0.5e-3;N=10;Th=1e-12;M1=2;M2=1000;td=0.0e-3;
% a0=A*tau/T0
% a0=0 %average of f(t) = zero
a0=A/2 %triangular, sawtooth

14
% F=A*d*sinc(n*d).*exp(-1j*n*w0*td) %rectangular
F=A*d*sinc(n*d).^2.*exp(-1j*n*w0*td) %triangular
% F=1j*A./(2*pi*n).*exp(-1j*n*w0*td) %sawtooth
F(N+1)=a0 %triangular, sawtooth

% f0a=0.5*(1+square(2*pi*(t-td+tau/2)/T0,100*tau/T0)); %rectangular
f0a=0.5*(1+sawtooth(2*pi*(t-td+T0/2)/T0,0.5)); %triangular

Approximation of f(t) with DC + up to 10th Harmonic

1
f (t)

0.5

-2 -1.5 -1 -0.5 0 0.5 1 1.5 2


-3
t 10

0.5

0.4

0.3
|F n |

0.2

0.1

0
-10 -9 -8 -7 -6 -5 -4 -3 -2 -1 0 1 2 3 4 5 6 7 8 9 10

f (kHz)

2.4 Change input to sawtooth pulse train:

% F=A*d*sinc(n*d).*exp(-1j*n*w0*td) %rectangular
% F=A*d*sinc(n*d).^2.*exp(-1j*n*w0*td) %triangular
F=1j*A./(2*pi*n).*exp(-1j*n*w0*td) %sawtooth
F(N+1)=a0 %triangular, sawtooth
% f0a=0.5*(1+square(2*pi*(t-td+tau/2)/T0,100*tau/T0)); %rectangular
% % f0a=0.5*(1+sawtooth(2*pi*(t-td+T0/2)/T0,0.5)); %triangular
f0a=0.5*(1+sawtooth(2*pi*(t+0*T0)/T0,1)); %Sawtooth

Approximation of f(t) with DC + up to 10th Harmonic

1
f (t)

0.5

-2 -1.5 -1 -0.5 0 0.5 1 1.5 2


-3
t 10

15
0.5

0.4

0.3
|F n |

0.2

0.1

0
-10 -9 -8 -7 -6 -5 -4 -3 -2 -1 0 1 2 3 4 5 6 7 8 9 10

f (kHz)

2.5 Change back to rectangular pulse train with duty cycle 0.5 and td = 0. Change RC circuit to
CR circuit with R = 1 kΩ and C = 1 µF.
C

g(t) R
y (t)

% H=(1/(R*C))./(1j*n*w0+(1/(R*C))) %RC LPF


H=(1j*n*w0)./(1j*n*w0+(1/(R*C))) %CR HPF

Approximation of y(t) with DC + up to 10th Harmonic


1

0.5
(t)

0
y

-0.5

-1

-2 -1.5 -1 -0.5 0 0.5 1 1.5 2


-3
t 10

16

You might also like