%question1 %function a function y=a(t) y=10*cos(100*pi*t); %function b function y=b(t) y=40*cos(60*pi*t) + 20*sin(40*pi*t); t = -0.1:0.0001:0.1; figure plot(t, a(t)); % Plot the signal a figure plot(t, b(t)); % Plot the signal b %question1a Ta=0.02; t = -Ta/2:0.0001:Ta/2; energya = trapz(t, a(t).^2) powera = energya /Ta disp(['Energy of the a signal is: ', num2str(energya)]) disp(['Power of the a signal is: ', num2str(powera)]) Tb=0.1; t = -Tb/2:0.0001:Tb/2; energyb = trapz(t, b(t).^2) powerb = energyb /Tb disp(['Energy of the a signal is: ', num2str(energyb)]) disp(['Power of the a signal is: ', num2str(powerb)]) %question1b Tb=0.1; t = -Tb/2:0.0001:Tb/2; ab=a(t)+b(t); plot(t, ab); % Plot the signal ab energyab = trapz(t, ab.^2) powerab = energyab / Tb; disp(['Energy of the ab signal is: ', num2str(energyab)]) disp(['Power of the ab signal is: ', num2str(powerab)]) %question2 %first define the functions function y=f1(n) y=2*((0.9).^n).*sin((2*pi*n)/4); %first define the function function y=f2(n) y=(cos((2*pi*(n+1))/12).*stepDT(n+1)) - (cos((pi*n)/6).*stepDT(n)); %first define the function function y=f3(n) y=((3*n+6)/10).*exp(-2*n); %in command window n=-100:100; n3=-1:0.1:10; subplot(3,1,1) stem(n, f1(n),'r') subplot(3,1,2) stem(n, f2(n),'k') subplot(3,1,3) stem(n3, f3(n3),'m') %in command window n=-100:100; n3=-1:0.1:10; energy1=sum(abs(f1(n)).^2); power1=energy1/length(n); disp(['Energy of the 1st signal is : ', num2str(energy1)]) disp(['Power of the 1st signal is : ', num2str(power1)]) energy2=sum(abs(f2(n)).^2); power2=energy2/length(n); disp(['Energy of the 2nd signal is : ', num2str(energy2)]) disp(['Power of the 2nd signal is : ', num2str(power2)]) energy3=sum(abs(f3(n3)).^2); power3=energy3/length(n3); disp(['Energy of the 3rd signal is : ', num2str(energy3)]) disp(['Power of the 3rd signal is : ', num2str(power3)])