summaryrefslogtreecommitdiff
path: root/3809/CH8/EX8.4/EX8_4.sce
diff options
context:
space:
mode:
Diffstat (limited to '3809/CH8/EX8.4/EX8_4.sce')
-rw-r--r--3809/CH8/EX8.4/EX8_4.sce34
1 files changed, 34 insertions, 0 deletions
diff --git a/3809/CH8/EX8.4/EX8_4.sce b/3809/CH8/EX8.4/EX8_4.sce
new file mode 100644
index 000000000..76dcbc22a
--- /dev/null
+++ b/3809/CH8/EX8.4/EX8_4.sce
@@ -0,0 +1,34 @@
+//Chapter 8, Example 8.4
+funcprot()
+clc
+//Initialisation
+p1=20 //gain
+p2=30 //gain
+p3=40 //gain
+
+
+
+//initialising a function for gain
+function [x]=pgain(a) //function for power gain
+ x=10**(a/10)
+endfunction
+
+function [x]=vgain(a) //function for voltage gain
+ x=10**(a/20)
+endfunction
+
+//calling a functions
+[pd1]=pgain(p1)
+[pd2]=pgain(p2)
+[pd3]=pgain(p3)
+[vd1]=vgain(p1)
+[vd2]=vgain(p2)
+[vd3]=vgain(p3)
+
+//Result
+printf("Power Gain (dB) of 20 = %.1f dB\n",pd1)
+printf("Voltage Gain (dB) of 30 = %.1f dB\n\n",vd1)
+printf("Power Gain (dB) of 40 = %.1f dB\n",pd2)
+printf("Voltage Gain (dB) of 20 = %.1f dB\n\n",vd2)
+printf("Power Gain (dB) of 30 = %.1f dB\n",pd3)
+printf("Voltage Gain (dB) of 40 = %.1f dB\n",vd3)