Question

Problem 2: A periodic signalxit) is shown below A =10, T-4 sec. -T Write a MATLAB script to plot the signal, using enough poi

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Problem:2

a)For N=6

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

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


clc;
clear all;
close all;
T=4;t=0:0.01:T;A=10;
x=(A*(1-(t/4)))
t1=linspace(-20,20,10*length(t))
x1=[x x x x x x x x x x]
subplot(3,2,[1,2])
plot(t1,x1,'r')
xlabel('t')
ylabel('x(t)')
title('Periodic signal x(t)')
subplot(323)
plot(t,x,'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=6
t=0:0.01:T
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(324)
stem(n,abs(a))
title('Amplitude spectra')
xlabel('k..>')
ylabel('|ak|')

subplot(325)
stem(n,angle(a))
title('Phase spectra')
xlabel('k..>')
ylabel('<ak>')

%output xN(t) for N=6
[xN,t]=ctfss(a,T,N)
subplot(326)
plot(t,xN,'r',t,x,'b')
title('xN(t) for N=6')
xlabel('t')
ylabel('xN(t)')


Periodic signal x(t) 10 20 10 -10 -20 Amplitude spectra one period of x(t) 4 4 6 -42 0 4 3 xN(t) for N-6 Phase spectra 12 10

b)N=64


clc;
clear all;
close all;
T=4;t=0:0.01:T;A=10;
x=(A*(1-(t/4)))
t1=linspace(-20,20,10*length(t))
x1=[x x x x x x x x x x]
subplot(3,2,[1,2])
plot(t1,x1,'r')
xlabel('t')
ylabel('x(t)')
title('Periodic signal x(t)')
subplot(323)
plot(t,x,'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=64
t=0:0.01:T
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(324)
stem(n,abs(a))
title('Amplitude spectra')
xlabel('k..>')
ylabel('|ak|')

subplot(325)
stem(n,angle(a))
title('Phase spectra')
xlabel('k..>')
ylabel('<ak>')

%output xN(t) for N=64
[xN,t]=ctfss(a,T,N)
subplot(326)
plot(t,xN,'r',t,x,'b')
title('xN(t) for N=64')
xlabel('t')
ylabel('xN(t)')


Periodic signal x(t) 10 -20 -10 10 20 one period of x(t) Amplitude spectra 4 ー3 -50 100 50 3 4 100 Phase spectra XN(t) for N-

Add a comment
Know the answer?
Add Answer to:
Problem 2: A periodic signalxit) is shown below A =10, T-4 sec. -T Write a MATLAB script to plot ...
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