Code for problems 1 and 4 and notes on the solution of Problem 1, Homework 3 of Math 5467

 

Problem 1

1. This is a problem of integration by parts.

 

2. Note that f(t) satisfies the hypothesis of the Fourier Convergence Theorem.

Also, f(t) is continuous and has a piecewise continuous derivative on its domain and the function is band-limited with \Omega =1 Thus, we can safely apply the Shannon-Whitaker sampling theorem.

 

3. Run the Matlab-code. You will see that the reconstructed function is very close to the

original function. Note for the graph that even though f(0) is well defined, (use LíHospitalís Theorem or expansion in power series) you canít just blindly set t=0 inpart 2 to get f(0), becauseyou will have 0/0.

 

 

 

%%%% Code for Homework 3 of Math 5467 Spring 2004

%%%% Coded by the Grader of the Course (March 25, 2004)

 

clear all;

 

close all;

 

 

†††††††† %%%%Using Shannon-Whitaker Sampling Equations

 

 

%%%% Problem 1

 

disp ('Problem 1');

 

cnt =1;

 

 

for t=-50:0.17:50††

 

††† f(cnt)=0;

 

for x=-15:1:15

 

††† den= power(x*pi,3);

 

††† if x ~=0

 

††† f(cnt)= f(cnt)+ (2/pi)*( (sin(x*pi)-(x*pi)*cos(x*pi))/den ) *(sin(t-x*pi)/(t-x*pi));

 

††† else†††††††††††

 

††† f(cnt)= f(cnt) + 0.212207 *(sin(t-x*pi)/(t-x*pi)); %% I calculated the limit as x->0

 

††† end;

 

end;

 

cnt =cnt+1;

 

end;

 

 

††† tstep= -50:.17:50;

 

††† figure, plot(tstep,f,'r');

 

†††

 

††† %%%The Original Function

 

cnt =1;

 

for t=-50:0.17:50†† %%% 0.17 to make sure that t will NOT equal 0.

 

††† f0(cnt)=0;

 

††† if t ~=0

 

††† f0(cnt)= f0(cnt)+ (2/pi)*(sin(t)-t*cos(t))/(t*t*t);

 

††† cnt =cnt+1;

 

††† else

 

††† f0(cnt)= f0(cnt)+ 0.212207;

 

††† cnt =cnt+1;

 

††† end;

 

end;

 

 

hold on

 

plot(tstep,f0,'b'),

 

title('Shannon-Sampling Theorem'), xlabel('time'),ylabel('f(t)');

 

legend('From Shannon-Sampling Theorem', 'The Original Function');

 

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

 

%%%% Problem 4

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

 

disp ('Problem 4');

 

 

maxk=256;

 

 

for k = 0:maxk-1

 

††† ts = 2*k*pi/maxk;

 

f4(k+1) = exp(-ts*ts/10)* ( sin(ts)+ 2*cos(2*ts)+ 0.5*sin(ts)*sin(60*ts) );

 

end;

 

 

Ff4= fft(f4,maxk);

 

Ff4m6= Ff4;

 

Ff4m6(6:maxk-5)=0;

 

invFf4m6=ifft(Ff4m6,maxk);

 

figure, plot(f4), hold on, plot(real(invFf4m6),'r'), title('Plot of the discretized signal and the filtered one');