summaryrefslogtreecommitdiff
path: root/716/CH2/EX2.4.a/Solved_Ex2_4a.sce
diff options
context:
space:
mode:
Diffstat (limited to '716/CH2/EX2.4.a/Solved_Ex2_4a.sce')
-rwxr-xr-x716/CH2/EX2.4.a/Solved_Ex2_4a.sce20
1 files changed, 20 insertions, 0 deletions
diff --git a/716/CH2/EX2.4.a/Solved_Ex2_4a.sce b/716/CH2/EX2.4.a/Solved_Ex2_4a.sce
new file mode 100755
index 000000000..fdd84d7d3
--- /dev/null
+++ b/716/CH2/EX2.4.a/Solved_Ex2_4a.sce
@@ -0,0 +1,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='); \ No newline at end of file