blob: fdd84d7d3e087c1992f8982144686fe56a7928b8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
//find power and energy of periodic signal x(t)=exp(-2t)*u(t)
clc;
//To plot signal*************************//
t=-5:0.01:5;
x=exp(-2*t).*(t>=0);//given signal
plot(t,x);
//**************************************//
t=-50:0.01:50;
x=exp(-2*t).*(t>=0);
T=length(t);
//To calculate Energy
xsq=x.^2;//adds squares of all the 'x' values(integrates 'x^2' terms)
v=inttrap(t,xsq);
disp('joules',v,'Energy');
//To calculate Power
xsq=x.^2;
P=1/T*v;//divide by 2T,to take the average rate of energy(gives power)
disp('watts',P,'Power=');
|