Question

3. One period of a signal is given by the following equation: +1 1 0<t <3 x(t) = 3 NI+ 3 st 35 5 st 57 N Hint: Use the heavis

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

1)Script:

T=7;

w0=2*pi/T;

t=linspace(0,T,1000);

xt=(((t/2)+1).*(heaviside(t)-heaviside(t-3)))+((3-(t/2)).*(heaviside(t-3)-heaviside(t-5)))+(2.*(heaviside(t-5)-heaviside(t-7)));

tt=linspace(0,2*T,2*length(t));

x=[xt xt];

figure;subplot(311)

plot(tt,x);grid;xlabel('t');ylabel('x(t)')

title('Original function x(t)')

%complex exponential Fouier series

i=1;

for K=[7 15]

i=i+1;

m=0;

for k=-K:1:K

m=m+1;

C(m)=(1/T)*trapz(t,xt.*exp(-j*k*w0*t));

end

k=-K:1:K;

%plot x(t) using fs

m=0;

for tt=linspace(0,2*T,2*length(t));

m=m+1;

xNt(m)=sum(C.*(exp(j*k*w0*tt)));

end

tt=linspace(0,2*T,2*length(t));

subplot(3,1,i)

plot(tt,xNt,'r');grid;

xlabel('t');

ylabel('x(t)')

title(sprintf('Approximated x(t) using %d tersm',K))

end

Original function x(t) 2 1.5 (7) 0.5 2 12 14 8 10 t Approximated x(t) using 7 tersm 2 1.5 1 0 2 4 8 12 14 6 10 t Approximated

2)Script:

clc;close all;clear all;

T=7;w0=2*pi/T;

t=linspace(0,T,1000);

xt=(((t/2)+1).*(heaviside(t)-heaviside(t-3)))+((3-(t/2)).*(heaviside(t-3)-heaviside(t-5)))+(2.*(heaviside(t-5)-heaviside(t-7)));

t1=linspace(0,2*T,2*length(t));

x=[xt xt];

figure;

subplot(311);plot(t1,x,'b')

xlabel('t');grid;

ylabel('x(t)')

title('Original signal x(t)')

%Trigonometric Fourier series coefficients

i=1;

for K=[11 17];

i=i+1;

a0=(1/T).*trapz(t,xt);

k=0;

for n=1:1:K

k=k+1;

an(k)=(trapz(t,xt.*cos(n*w0*t)));

end

an=2*an/T;

k=0;

for n=1:1:K

k=k+1;

bn(k)=(trapz(t,xt.*sin(n*w0*t)));

end

bn=2*bn/T;

n=1:1:K;

%Reconstruction of original signal

k=0;

for t1=linspace(0,2*T,2*length(t))

k=k+1;

Xr(k)=a0+sum((an.*(cos(n.*w0*t1)))+(bn.*(sin(n*w0*t1))));

end

subplot(3,1,i)

t1=linspace(0,2*T,2*length(t));

plot(t1,Xr,'r')

xlabel('t');grid;

ylabel('x(t)')

title(sprintf('Approximated x(t) using %d terms',K))

end

Original signal x(t) 2 x(t) 1.5 0.5 2 8 10 12 14 Approximated x(t) using 11 terms 2 21.5 1 0 2 4 8 12 14 6 10 t Approximated

Add a comment
Know the answer?
Add Answer to:
3. One period of a signal is given by the following equation: +1 1 0<t <3...
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