Part 1
Q1:
t=-7:0.001:7;% st pt for plot:step:endpt for plot
y=exp(-abs(t)/5).*(t>=-1).*(t<=3);
% st pt for plot:step:endpt for plot
% we also can do this
%u1=t >= -1;
%u2 = t >= 3;
%y=exp(-abs(t)/5) .* (u1 - u2);
subplot(2,2,1);%%subplot rows columns position
plot(t,y);
y1=exp(-abs(3*t)/5).*(3*t>=-1).*(3*t<=3);
subplot(2,2,2);%subplot rows columns position
plot(t,y1);
y2=exp(-abs(t+2)/5).*((t+2)>=-1).*((t+2)<=3);
subplot(2,2,3);%subplot rows columns position
plot(t,y2);
y3=exp(-abs(4-2*t)/5).*((4-2*t)>=-1).*((4-2*t)<=3);
subplot(2,2,4);%subplot rows columns position
plot(t,y3);
Q2:a)
fs=5;%freq of sampling
Ts=1/fs;%sample period
t = linspace (-130000, 130000, 260000*fs) ;
%start,end,(Total number of pt.s=end-start*fs)
x = (10^ (-3))*t;
m = (sin(x)./x).^2;%%sinc squared
M = (Ts)*fftshift(fft(m)) ;
n = length (m) ;
f= (-n/2:n/2-1)*(fs/n) ;
w = 2*pi*f ;
plot (w, abs (M) );
title('fft tri signal');
xlabel('W');
ylabel('m(w)');
figure;
plot(t,m);
title('sinc squared');
xlabel('t');
ylabel('x(t)');
Q2:b)
fs = 4 ;
Ts = 1/fs ;
t = linspace (-150000, 150000, 300000*fs) ;
x = (10^-3)*t ;m =(sin(x)./x).^2 ;y= 2*pi*(10^5)*t;
r = m.*cos(y) ;
R = Ts*fftshift(fft(r)) ;
n = length (r);
f = (-n/2:n/2-1)*(fs/n);
w = 2*pi*f ;
plot (w, abs(R))
xlabel('w');
ylabel('R(w)');
figure;
plot(t,r)
xlabel('t');
ylabel('r(t)');
Q3:
syms t n real
x = exp(-t);
Dn = (1/pi) * int(x * exp(-2 .*n .* t .*j), t, 0, pi);
n = -5:5;
Dn_values = subs(Dn,n);
figure;
stem(n, abs(Dn_values), 'LineWidth', 1.5);
title('Magnitude of D_n');
xlabel('n');
ylabel('|D_n|');
grid on;
figure;
stem(n, angle(Dn_values)* ( 180/pi) , 'LineWidth', 1.5);
title('Phase of D_n');
xlabel('n');
ylabel('angle D_n (radians)');
grid on;
Part2: