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)')
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)')
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)')
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)')
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)')
Questions a) Write a (Matlab) function, which accepts the following inputs: -the finite set of Fo...
During lab 4, we have seen numerical implementation of Fourier Series for periodic signals. As first part of this assignment, you need to write a Matlab function that would take an array representing a single period of a signal (x), corresponding time array (t), and return the Fourier Series coefficients (Ck) in exponential form. The function should also be able to take two (2) optional input arguments: number of Fourier coefficients (Nk) and plot option (p). Use the template ‘fourier_series_exp.m’...
A periodic signal, x(t) is shown below. A = 10, T-4 sec. -T Write a MATLAB script to plot the signal, using enough points to get a smooth curve. Compute the Fourier series coefficients for the signal (if you can find them in the text, that is ok). Plot the single-sided or double-sided spectra for each signal. Include enough frequencies in the plots to adequately represent the frequency content of the signals. Plot partial sums of the Fourier series for...
Problem 2: A periodic signalxit) is shown below A =10, T-4 sec. -T Write a MATLAB script to plot the signal, using enough points to get a smooth curve. Compute the Fourier series coefficients for the signal (if you can find them in the text, that is ok). Plot the single-sided or double-sided spectra for each signal. Include enough frequencies in the plots to adequately represent the frequency content of the signals. Plot partial sums of the Fourier series for...
PLZ shows you Matlab Code X(t) 2 2 46 1. compute the Fourier Series coefficients, ck for the signal x(t) 2. plot magnitude of c and the phase of ck in separate plots (use subplot command) plot the Fourier Series coefficients for the square wave signal: ck(12/9) sinc(2"k/3)
Use MATLAB to : ("j" is the imaginary number.) The term lo is the fundamental frequency of the periodic signal, 2/T, where T is the period. Frequencies nlo, where n is an integer, are the harmonics. This infinite sum is an exact representation of the original function. If we use a finite sum, where n goes from -N to N, we will get an approximation "X-(t)". In this problem we will calculate and plot the Fourier series representation of a...
Hello, I'm taking signal systems course. please solve this question in matlab as soon as possbile please. Question 1 a) Write a function that calculates the Continuous Time Fourier Transform of a periodic signal x() Syntax: [w, X] = CTFT(t, x) The outputs to the function are: w = the frequencies in rad/s, and X = the continuous Fourier transform of the signal The inputs to the function are: x-one period of the signal x(t), andt the time vector The...
2.For the periodic DT signal shown in Top, a) determine the Fourier Series Coefficients. b) Use MATLAB to generate a spectral plot (magnitude plot and a separate phase plot). c) Use MATLAB to generate and plot the signal as a DTFS expansion of the periodic signal. Plot over an interval containing several periods. Make sure to include the MATLAB code x[ri] -9 63 3 9 12 n 1. For the periodic DT signal shown in Top, a) determine the Fourier...
1. For the function (t) below, T 2 and Vm-100 V. vt) 3 2 012 3 (a) Sketch v'(t) and derive the Fourier coefficients for '(t). (b) Use your results from part (a) to determine for Fourier coefficients for v(t). Express your solution in the complex form of the Fourier series, nugt and verify your solution by plotting your results using Matlab. 2. Assume that the signal above is the input to the bandpass filter shown below. y (t (a)...
Use Matlab to make a function that gives Fourier series coefficients. Function header: Function [average, aK, bK] = Func1(t, x, T, N)
could you please solve this problem using Matlab 4. Using the Fourier series coefficients {ak} obtained, construct the following signal N(t)>akekwot k=-N where ak is the kth Fourier series coefficients of r(t). Therefore, N(t) is the so-called 2N-term approximation of original signal r(t). In one figure, plot âN(t) versus t, for N 10, 20, 30, 40. In the same plot, also plot original signal (t). Visually compare N(t) and r(t) in the figure and comment on your observations