I. PREPARATION %question1 %first define the function function y=xdis(n) y=exp(-1*abs(n/10)).*sin((2*pi*n)/4); clear all n = -100:100; xn=xdis(n); stem(n,xn ); xnSq = xn .* xn; Ex = sum(xnSq); disp(['Energy of the signal is: ', num2str(Ex)]); Px = Ex/length(n); disp(['Power of the signal is: ', num2str(Px)]); %question2 n=-150:1:150; N=25; %Period of the signal periodicxdis=zeros(1,length(n)); for k=-5:5 periodicxdis=periodicxdis+xdis(n-k*N); end stem(n,periodicxdis) xn=periodicxdis; stem(n,xn); xnSq = xn.^2; Ex = sum(xnSq); disp(['Energy of the signal is: ', num2str(Ex)]); Px = Ex/N; disp(['Power of the signal is: ', num2str(Px)]); %question3 t = -10:0.01:10; gt = 5 * exp(-abs(t/2)) .* cos(2*pi*t); plot(t, gt); gtSq = gt.^2; % Use element-wise power operator instead of multiplication Ex = trapz(t, gtSq); Px = Ex/(max(t)-min(t)); disp(['The energy of the signal is: ', num2str(Ex)]); disp(['The power of the signal is: ', num2str(Px)]) %question4 %first define the function function y=xgt(t) y=5 * exp(-abs(t/2)) .* cos(2*pi*t); %in command window periodicxgt t=-150:150; N=25; periodicxgt=zeros(1,length(t)); for k=-5:5 periodicxgt=periodicxgt + xgt(t-k*N); end plot(t,periodicxgt) %in command window t=-150:150; xgtq = periodicxgt.^2; Ex = trapz(t, xgtq); Px = Ex/N; disp(['The energy of the signal is: ', num2str(Ex)]); disp(['The power of the signal is: ', num2str(Px)])