Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

USING MATLAB (or you can write just the code) Write a Matlab function [x, t] = f

ID: 3863067 • Letter: U

Question

USING MATLAB (or you can write just the code)

Write a Matlab function [x, t] = fs_approx (a, omega _0, tmin, tmax,  n). It is assumed that vector a = [a_- N a_- N + 1 ellipsis a_- 1 a_0 a_1 ellipsis a_N - 1 a_N]. Vector x contains n samples of the Fourier series approximation x_N(t) = sigma _k = - N^N a^k middot e^jk omega _0t between t = tmin (sec) and t = tmax (sec). Note that parameter omega _0 is the angular frequency of the original periodic signal from which Fourier coefficients in a were derived. Output vector t,  to be used for plotting, contains time reference for corresponding elements in x. Your program should check whether input vector a is of size 2N + 1 for some N greaterthanorequalto 0. It should also check whether tmax > fmin. Empty vectors, i.e.,  x = [] and t = [] should be returned if input parameters are not valid.

Explanation / Answer

Please refer below code

function [x,t] = fs_approx(a,w0,tmin,tmax,n)

if size(a) == (2 * n + 1) && tmax > 1/tmin
x = [];
t = [];
end

t = [0:1:100];
x = zeros(1,90);

for m = 0:1:100
sum = 0;
for k = -n:1:n
z = 1i;
sum = sum + a(k+n+1) .* exp(k .* t(m+1)* w0 * z);
end
x(m) = sum;
end