Professional Documents
Culture Documents
FIRST EXAMPLE:
syms t x1(t)
x1(t) = piecewise(t < 0 , 0, ... % Define x1 as a piecewise fn
0 < t < 2 , 3*t, ...
t > 2 , 6*exp(-(t-2)))
x1(t) =
figure('Visible', 'on')
fplot(x1(t), [-3 8], 'LineWidth', 2, 'Color', 'c')
title('1^{st} Example: Plot of x_1(t) vs t')
grid on;
xlabel('t');
ylabel('x_1(t)');
text(0.8, 3, '3t', 'FontSize', 14, 'Color', 'b', 'interpreter', 'latex', 'BackgroundColor', 'w')
text(2, 3, '$6e^{-(t-2)}$', 'FontSize', 14, 'Color', 'b', 'interpreter', 'latex')%, 'BackgroundColor',
'w')
axis([-3 8 0 7])
hold on
tt = -3:0.01:8;
area(tt, x1(tt).^2,'FaceColor','r','FaceAlpha', 0.25, 'EdgeColor', 'none');
E=
42
E_X=int((x1(t)).^2, t, 0, inf)
E_X =
42
Energy_X2 = integral(@(t)(x2(t).^2),0,inf)
Energy_X2 = 42.0000
SECOND EXAMPLE :
x2(t) = 4 * cos(2 * pi * t / 10);
T = 10; % Period of the periodic signal
hold on
tt = -14:0.01:88;
area(tt, x2(tt).^2,'FaceColor','r','FaceAlpha', 0.25, 'EdgeColor', 'none');
COMPUTE THE AVERAGE POWER IN THE SIGNAL:
Pav = (1/T) * int(x2(t)^2, t, -T/2, T/2) % <T> can be -T/2 < t < T/2, or any interval "T" wide
Pav =
Pav = (1/T) * int(x2(t)^2, t, 0, T) % <T> can be 0 < t < T, or any interval "T" wide
Pav =
x3(t) = t;
figure('Visible', 'on')
fplot(x3(t), [-10 10], 'LineWidth', 2, 'Color', 'c')
title('3^{rd} Example: Plot of x_3(t) vs t')
grid on;
xlabel('t');
ylabel('x_3(t)');
text(4, 6, '$t$', 'FontSize', 16, 'Color', 'b', 'Interpreter', 'latex')
axis([-10 10 -10 10])
hold on
fplot(x3(t)^2, [-10 10], 'LineWidth', 2, 'Color', 'g')
title('3^{rd} Example: Plot of Instantaneous Power of x_3(t) vs t')
grid on;
xlabel('t');
ylabel('$$p(t)=x_3^2(t) = t^2$$', 'FontSize', 14, 'Color', 'g', 'Interpreter', 'latex');
axis([-10 10 -10 100])
tt = -10:0.01:10;
area(tt, x3(tt).^2,'FaceColor','g','FaceAlpha', 0.25, 'EdgeColor', 'none');
E = int((t)^2, t, 0,inf)
E=