1. Write MATLAB codes to find the EVEN and ODD parts of the signal x(t)=e^2t
2. Write MATLAB codes to find the energy and power of the signal x(t)= 10 sin(10 πt)
close all,
clear all,
clc,
%1. Write MATLAB codes to find the EVEN and ODD parts of the signal x(t)=e^2t
Fs=100;
t=0:(1/Fs):1;
Xt = exp(2*t);
scrsz = get(0,'ScreenSize');
Dim=0;
figure('Position',[scrsz(1)+Dim, scrsz(2)+Dim,scrsz(3)-20,scrsz(4)-100]);
subplot(3,1,1); plot(t,Xt);
title('Original Signal');
xlabel('Time (s)');
ylabel('--- X(t) --->');
title('x(t) = e^{2t}','FontSize',20);
grid on,
Xf=fliplr(Xt);
Xod=1/2*(Xt+Xf);
Xevn=1/2*(Xt-Xf);
subplot(3,1,2);
plot(Xod);
xlabel('Time (s)');
ylabel('--- X(t) --->');
title('Odd Part of x(t) = e^{2t}','FontSize',20);
grid on,
subplot(3,1,3);
plot(Xevn);
xlabel('Time (s)');
ylabel('--- X(t) --->');
title('Even Part of x(t) = e^{2t}','FontSize',20);
grid on,
close all,
clear all,
clc,
%2. Write MATLAB codes to find the energy and power of the signal x(t)= 10 sin(10 πt)
Fs=100;
t = 0:(1/Fs):1;
Xt = [];
Energy = 0;
Power = 0;
Xt = 10*sin(10*pi*t);
for r=1:length(t)
Energy = Energy + Xt(r)*Xt(r);
end
scrsz = get(0,'ScreenSize');
Dim=0;
figure('Position',[scrsz(1)+Dim, scrsz(2)+Dim,scrsz(3)-20,scrsz(4)-100]);
plot(t,Xt);
xlabel('--- Time (t) ---');
ylabel('--- X(t) --->');
title('Xt = 10*sin(10*pi*t)','FontSize',20);
grid on,
Power = Energy/length(Xt);
fprintf('\n\tEnergy = %.3f',Energy);
fprintf('\n\tPower = %.3f',Power);
Energy = 5000.000
Power = 49.505
Comments
Leave a comment