Question

Questions a) Write a (Matlab) function, which accepts the following inputs: -the finite set of Fourier series coefficients a-b) Consider the following signal 4 x(t)- 4 1- x(t) is periodic with period T-3s. Plot x(t) for the time interval t3 and t 3 (

Questions a) Write a (Matlab) function, which accepts the following inputs: -the finite set of Fourier series coefficients a-N, a-N+1,.. , a-1, ao, a1, aN-1, aN the fundamental period T of the signal to be reconstructed a vector t representing the times for which the signal will be constructed - and produces as output xv(t) (i.e., the output of the (Matlab) function should be a vector x of length equal to the length of t containing the values of xN at the times indicated by t)
b) Consider the following signal 4 x(t)- 4 1- x(t) is periodic with period T-3s. Plot x(t) for the time interval t3 and t 3 (in increments of 0.1) 2- Analytically derive the Fourier series coefficients for the signal x(t). Show all steps of your derivation. 3- Using the (Matlab) function derived in question a), plot xv(t) for N-3, 5, 11, 32, 100 for the time interval t3 and t-3. Note that you will have to write a (Matlab) code that generates the coefficients for different N 4- Analyze the results obtained in question 3 Explain why you observe the presence of high frequencies ripples in proximity of the discontinuities What do you notice about the ripples as you increase N? What you can say about the peak value of the ripples as you increase N?
0 0
Add a comment Improve this question Transcribed image text
Answer #1

1)Function script:(save it as ctfss.m and neglect the error during execution)

function [y,t]=ctfss(an,T,N)
k=0;
w0=2*pi/T;
n=-N:1:N
for t=-T:0.01:T
k=k+1;
xN(k)=sum(an.*(exp(j*n*w0*t)));
end
t=-T:0.01:T
y=xN
endfunction

2)MAIN SCRIPT: save it in any name as you wish and execute after the execution of ctfss,m

a)For N=3

clc;
clear all;
close all;
T=3;tt=-3:0.1:3;
xx=(tt>=-3 &tt<=-2.25)+(tt>=-3/4 &tt<=3/4)+(tt>=2.25 &tt<=3)
figure;
subplot(221)
plot(tt,xx,'r')
xlabel('t')
ylabel('x(t)')
title('one period of x(t)')

%To caclculate fourier series coefficients of x(t)
w0=2*pi/T;N=3
%One period of the periodic signal
t=-1.5:0.1:1.5;
x=(t>=-3/4 &t<=3/4)
k=0;
for n=-N:1:N
k=k+1;
a(k)=(trapz(t,x.*exp(-j*n*w0*t)));
end
a=a/T
n=-N:1:N
subplot(222)
stem(n,abs(a))
title('Amplitude spectrum of an')
xlabel('k..>')
ylabel('|ak|')
subplot(223)
stem(n,angle(a))
title('Phase spectrum of an')
xlabel('k..>')
ylabel('<ak>')

%output xN(t) for N=3
[xN,t]=ctfss(a,T,N)
subplot(224)
plot(t,xN,'r',tt,xx,'b')
title('xN(t) for N=3')
xlabel('t')
ylabel('xN(t)')

one period of x(t) Amplitude spectrum of an 0.7 0.6 0.5 0.4 0.3 0.2 0.1 0.8 0.6 0.4 0.2 -3 2 3 3 -21 Phase spectrum of an XN(

b) ForN=5

clc;
clear all;
close all;
T=3;tt=-3:0.1:3;
xx=(tt>=-3 &tt<=-2.25)+(tt>=-3/4 &tt<=3/4)+(tt>=2.25 &tt<=3)
figure;
subplot(221)
plot(tt,xx,'r')
xlabel('t')
ylabel('x(t)')
title('one period of x(t)')

%To caclculate fourier series coefficients of x(t)
w0=2*pi/T;N=5
%One period of the periodic signal
t=-1.5:0.1:1.5;
x=(t>=-3/4 &t<=3/4)
k=0;
for n=-N:1:N
k=k+1;
a(k)=(trapz(t,x.*exp(-j*n*w0*t)));
end
a=a/T
n=-N:1:N
subplot(222)
stem(n,abs(a))
title('Amplitude spectrum of an')
xlabel('k..>')
ylabel('|ak|')
subplot(223)
stem(n,angle(a))
title('Phase spectrum of an')
xlabel('k..>')
ylabel('<ak>')

%output xN(t) for N=5
[xN,t]=ctfss(a,T,N)
subplot(224)
plot(t,xN,'r',tt,xx,'b')
title('xN(t) for N=5')
xlabel('t')
ylabel('xN(t)')

one period of x(t) Amplitude spectrum of an 0.7 0.6 0.5 0.4 0.3 0.2 0.1 0.8 0.6 0.4 0.2 -3 2 2 3 6 -4 4 Phase spectrum of an

c)For N=11

clc;
clear all;
close all;
T=3;tt=-3:0.1:3;
xx=(tt>=-3 &tt<=-2.25)+(tt>=-3/4 &tt<=3/4)+(tt>=2.25 &tt<=3)
figure;
subplot(221)
plot(tt,xx,'r')
xlabel('t')
ylabel('x(t)')
title('one period of x(t)')

%To caclculate fourier series coefficients of x(t)
w0=2*pi/T;N=11
%One period of the periodic signal
t=-1.5:0.1:1.5;
x=(t>=-3/4 &t<=3/4)
k=0;
for n=-N:1:N
k=k+1;
a(k)=(trapz(t,x.*exp(-j*n*w0*t)));
end
a=a/T
n=-N:1:N
subplot(222)
stem(n,abs(a))
title('Amplitude spectrum of an')
xlabel('k..>')
ylabel('|ak|')
subplot(223)
stem(n,angle(a))
title('Phase spectrum of an')
xlabel('k..>')
ylabel('<ak>')

%output xN(t) for N=11
[xN,t]=ctfss(a,T,N)
subplot(224)
plot(t,xN,'r',tt,xx,'b')
title('xN(t) for N=11')
xlabel('t')
ylabel('xN(t)')

one period of x(t) Amplitude spectrum of an 0.7 0.6 0.5 0.4 0.3 0.2 0.1 0.8 0.6 0.4 0.2 15 105 0 -3 2 2 3 5 10 15 Phase spect

d)For N=32

clc;
clear all;
close all;
T=3;tt=-3:0.1:3;
xx=(tt>=-3 &tt<=-2.25)+(tt>=-3/4 &tt<=3/4)+(tt>=2.25 &tt<=3)
figure;
subplot(221)
plot(tt,xx,'r')
xlabel('t')
ylabel('x(t)')
title('one period of x(t)')

%To caclculate fourier series coefficients of x(t)
w0=2*pi/T;N=32
%One period of the periodic signal
t=-1.5:0.1:1.5;
x=(t>=-3/4 &t<=3/4)
k=0;
for n=-N:1:N
k=k+1;
a(k)=(trapz(t,x.*exp(-j*n*w0*t)));
end
a=a/T
n=-N:1:N
subplot(222)
stem(n,abs(a))
title('Amplitude spectrum of an')
xlabel('k..>')
ylabel('|ak|')
subplot(223)
stem(n,angle(a))
title('Phase spectrum of an')
xlabel('k..>')
ylabel('<ak>')

%output xN(t) for N=32
[xN,t]=ctfss(a,T,N)
subplot(224)
plot(t,xN,'r',tt,xx,'b')
title('xN(t) for N=32')
xlabel('t')
ylabel('xN(t)')

one period of x(t) Amplitude spectrum of an 0.7 0.6 0.5 0.4 0.3 0.2 0.1 0.8 0.6 0.4 0.2 40 20 20 40 -3 2 Phase spectrum of an

e) For N=100

clc;
clear all;
close all;
T=3;tt=-3:0.1:3;
xx=(tt>=-3 &tt<=-2.25)+(tt>=-3/4 &tt<=3/4)+(tt>=2.25 &tt<=3)
figure;
subplot(221)
plot(tt,xx,'r')
xlabel('t')
ylabel('x(t)')
title('one period of x(t)')

%To caclculate fourier series coefficients of x(t)
w0=2*pi/T;N=100
%One period of the periodic signal
t=-1.5:0.1:1.5;
x=(t>=-3/4 &t<=3/4)
k=0;
for n=-N:1:N
k=k+1;
a(k)=(trapz(t,x.*exp(-j*n*w0*t)));
end
a=a/T
n=-N:1:N
subplot(222)
stem(n,abs(a))
title('Amplitude spectrum of an')
xlabel('k..>')
ylabel('|ak|')
subplot(223)
stem(n,angle(a))
title('Phase spectrum of an')
xlabel('k..>')
ylabel('<ak>')

%output xN(t) for N=100
[xN,t]=ctfss(a,T,N)
subplot(224)
plot(t,xN,'r',tt,xx,'b')
title('xN(t) for N=100')
xlabel('t')
ylabel('xN(t)')

one period of x(t) Amplitude spectrum of an 0.7 0.6 0.5 0.4 0.3 0.2 0.1 0.8 0.6 0.4 0.2 -50 50 -3 2 100 -100 Phase spectrum o

Add a comment
Know the answer?
Add Answer to:
Questions a) Write a (Matlab) function, which accepts the following inputs: -the finite set of Fo...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT