diff options
Diffstat (limited to 'Analog_Communication_by_V_Chandrasekar')
8 files changed, 3117 insertions, 0 deletions
diff --git a/Analog_Communication_by_V_Chandrasekar/2-Signals_An_Introduction.ipynb b/Analog_Communication_by_V_Chandrasekar/2-Signals_An_Introduction.ipynb new file mode 100644 index 0000000..ef22dd7 --- /dev/null +++ b/Analog_Communication_by_V_Chandrasekar/2-Signals_An_Introduction.ipynb @@ -0,0 +1,377 @@ +{ +"cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Chapter 2: Signals An Introduction" + ] + }, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2.10: Laplace_Transform.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"\n", +"\n", +"//x(t) = del(t)\n", +"syms t s;\n", +"\n", +"L =laplace('delta(t)',t,s)\n", +"disp(L)\n", +"// x(t) = u(t)\n", +"\n", +"L1 =laplace('1',t,s);\n", +"disp(L1)\n", +"//x(t) = sin(w0*t)u(t)\n", +"\n", +"L2 =laplace('sin(w0*t)',t,s);\n", +"disp(L2)" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2.11: Z_transform.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"\n", +"clc;\n", +"clear;\n", +"\n", +"// a) z-transform of unit impulse function\n", +"syms n z;\n", +"x=1;\n", +"X=symsum(x*(z^-n),n,0,0);\n", +"disp(X,'X(z)=');\n", +"\n", +"//b) z-transform of unit step function\n", +"\n", +"y=ones(1);\n", +"Y=symsum(y*(z^-n),n,0,%inf);\n", +"disp(Y,'Y(z)=');" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2.1_A: Periodicity.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"\n", +"clear;\n", +"clc;\n", +" //a) periodicity os 5sin(6t-pi/4)\n", +"t=0:0.001:1;\n", +"w=6;\n", +"theta=%pi/4;\n", +"T=2*%pi/w;\n", +"x=cos(t*w+theta);\n", +"y=cos((t+T)*w+theta);\n", +"if ceil(x)==ceil(y) then\n", +" disp(' a) cos(6t+pi/4) is periodic with T=2*pi/6 (sec) ')\n", +" \n", +"else\n", +" disp('nonperiodic')\n", +"end\n", +"\n", +"\n", +" //b) periodicity of e^(j3t)\n", +" \n", +" w=3; \n", +" t=0:0.001:1;\n", +" T=2*%pi/w;\n", +" x=exp(3*%i*t);\n", +" y=exp(3*%i*(t+T));\n", +" if ceil(x)==ceil(y) then\n", +" disp(' b) exp(j3t) is periodic with T=2*pi/3 (sec) ')\n", +" \n", +"else\n", +" disp('nonperiodic')\n", +"end\n", +" \n", +" \n", +" //c) periodicity of cot(3t+theta)\n", +" \n", +" t=0:0.001:1;\n", +"w=5;\n", +"T=%pi/w;\n", +"\n", +" x=cotg(t*w+theta);\n", +" y=cotg((t+T)*w+theta);\n", +"if ceil(x)==ceil(y) then\n", +" disp(' c) cot(3t+Theta) is periodic with T=pi/5 (sec) ')\n", +" \n", +"else\n", +" disp('nonperiodic')\n", +"end\n", +" \n", +" " + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2.2_A: Even_and_Odd_Part_of_function.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"clear;\n", +"t = 0:1:10;\n", +"\n", +"for i = 1:length(t)\n", +" x(i) = (t(i)^6) + 2*(t(i)^4)+ 3*(t(i)^2)+4 ;\n", +"end\n", +"\n", +"for i = 1:length(t)\n", +" y(i) = ((-t(i))^6)+ 2*((-t(i))^4)+ 3*((-t(i))^2)+4 ;\n", +"end\n", +"\n", +"// checking if the function is even x(t)=x(-t)\n", +"if x==y then\n", +" disp('the function is even');\n", +"end\n", +"//odd part of the signal=0.5(x(t)-x(-t))\n", +"\n", +"z=0.5*(x-y);\n", +"if z==0 then\n", +" disp('the odd part is 0')\n", +"end" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2.2: Real_and_Imaginary_part.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"clear;\n", +"\n", +"/// e^j(*2*pi*f*t+theta)\n", +"\n", +"syms pi f0 t theta A\n", +"K=2*pi*f0*t+theta;\n", +"\n", +"disp('the given signal is complex');\n", +"disp('e^(j*theta) can be written as');\n", +"disp('cos(theta)+j*sin(theta)');\n", +"\n", +"Re=A*cos(K);\n", +"Img=A*sin(K);\n", +"mag=sqrt(Re^2+Img^2);\n", +"\n", +"disp(Re,'real part is ');\n", +"disp(Img,'the imaginary part ');\n", +"disp(mag,'Magnitude of signal is |A|=');\n", +"disp(K,'phase of the signal ');" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2.3_A: Power_and_Rms_power_of_Signal.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +" //x(t)=5u(t)....\n", +" amp=5; //amplitude is 5\n", +"t=0:0.01:1;\n", +"x0=0;\n", +"x1=0:0.1:10; // over a time interval of T\n", +"disp('the power of the signal (in watts) is');\n", +" X=(integrate('25','x',x0,10)/(2*10)); // power of the signal\n", +"disp(X);\n", +"\n", +"rms=amp/sqrt(2);\n", +"disp(rms,'the rms value of power is (in watts)');" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2.3: Energy_of_Signal.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"clear;\n", +"\n", +"//x(t)=2 over an interval of (-2,2)\n", +"\n", +"disp('the energy of the signal (in J)is');\n", +" Ex=(integrate('4','x',-2,2)); // energy content of the signal\n", +"disp(Ex);" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2.5: Properties_of_Impulse_Signal.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"clear;\n", +"\n", +"\n", +"//delta(t)\n", +"\n", +" for j = 1:1000\n", +" if j==1\n", +" delta(j)=1;\n", +" else\n", +" delta(j)=0;\n", +" end\n", +" end\n", +"\n", +"// a)\n", +"figure(1)\n", +" t=-1;\n", +" plot2d4(t,0);\n", +" for j=1:1:10\n", +" t=t+1;\n", +" z(j)=(cosd(j-1)*delta(j));\n", +" plot2d3(t,z(j));\n", +" disp(z(j));\n", +" \n", +" end\n", +"\n", +"\n", +"//b)\n", +"figure(2)\n", +" t=1.5;\n", +" plot2d4(t,0);\n", +" for j=3:1:10\n", +" t=t+1;\n", +" z(j)=abs(cosd(2.5)*delta(2*j-5));\n", +" plot2d3(t,z(j));\n", +" \n", +" end\n", +"\n", +"//c)\n", +"syms t;\n", +"\n", +"A=(-1)*exp(-1*t); //property 8\n", +"disp(diff(A,t));\n", +"\n", +"disp('when t=3');\n", +"\n", +"A=exp(-3);\n", +"disp(A);\n", +"\n", +"\n", +"\n", +" \n", +"\n", +"\n", +"\n", +"\n", +"\n", +"\n", +" " + ] + } +], +"metadata": { + "kernelspec": { + "display_name": "Scilab", + "language": "scilab", + "name": "scilab" + }, + "language_info": { + "file_extension": ".sce", + "help_links": [ + { + "text": "MetaKernel Magics", + "url": "https://github.com/calysto/metakernel/blob/master/metakernel/magics/README.md" + } + ], + "mimetype": "text/x-octave", + "name": "scilab", + "version": "0.7.1" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/Analog_Communication_by_V_Chandrasekar/3-Amplitude_Modulation.ipynb b/Analog_Communication_by_V_Chandrasekar/3-Amplitude_Modulation.ipynb new file mode 100644 index 0000000..40610a5 --- /dev/null +++ b/Analog_Communication_by_V_Chandrasekar/3-Amplitude_Modulation.ipynb @@ -0,0 +1,488 @@ +{ +"cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Chapter 3: Amplitude Modulation" + ] + }, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 3.1_A: AM_Sidebands.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"clear;\n", +"Fc=500;//carrier frequency in kHz\n", +"Fm=1;// message signal frequency in kHz\n", +"//a)\n", +"\n", +"USB=Fc+Fm;\n", +"LSB=Fc-Fm;\n", +"disp(USB,'USBI(in kHZ)=');\n", +"disp(LSB,'LSB(in kHz)=');\n", +"\n", +"//b)\n", +"\n", +"Bandwidth=USB-LSB;\n", +"disp(Bandwidth,'Bandwidth(in kHZ)=')\n", +"//c)\n", +"\n", +"Fm=1.5;//message signal frequency in kHz\n", +"\n", +"USB1=Fc+Fm;\n", +"LSB1=Fc-Fm;\n", +"disp(USB1,'USB(in kHz)=');\n", +"disp(LSB1,'LSB(in kHZ)=');\n", +"\n", +"\n", +"//d)\n", +"\n", +"Amplitude=[0 0 0 0 0 0 0 0 0 5 10 5 0]; //sample values as denoted in textbook\n", +"frequency=490:1:502;\n", +"\n", +" plot2d3(frequency,Amplitude); \n", +"xlabel('Frequency(in kHZ)');\n", +"ylabel('Amplitude(in V)');" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 3.1: amplitude_modulatio.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"clear;\n", +"Vm=3;// amplitude of message signal in V\n", +"Vc=5;//amplitude of carrier signal in V\n", +"m=Vm/Vc; //modulation index\n", +"disp('modulation index');\n", +"disp(m,'=');\n", +"disp('Upper Sideband Frequency(in MHz)');\n", +"Fm=4;//Frequency in KHz\n", +"Fc=5;//Frequency in MHz\n", +"disp(Fc+(Fm*10^(-3)),'=');\n", +"disp('Lower Sideband Frequency(in MHz)');\n", +"disp(Fc-(Fm*10^(-3)),'=');\n", +"disp('AMplitude of each Sideband(in V)');\n", +"disp(m*Vc/2,'=');" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 3.2_A: Amplitude_Modulatio.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"\n", +"\n", +"Fm=3; //frequency of message signal\n", +"Fc=8; //frequency of carrier signal\n", +"Ea=5;\n", +"Eb=10;\n", +"m=Ea/Eb; //modulation index\n", +"\n", +"disp(m,'m=');\n", +"USf=Fc+Fm*10^(-3);//Upper Sideband frequency\n", +"LSf=Fc-Fm*10^(-3);//Lower sideband frequency\n", +"disp(USf,'USf(Mhz)=');\n", +"disp(LSf,'LSf(Mhz)=');\n", +"Amp=m*Eb/2;// amplitude of each sideband\n", +"disp(Amp,'amp(v)=');\n", +"\n", +"\n", +"\n", +"function[x,Vm,Vc]=ampmod(Ea,Eb,m,Fc,Fm)\n", +" t=0:0.005:5;\n", +" \n", +" Vm = Ea*sin(2*%pi*Fm*t);\n", +" Vc = Eb*sin(2*%pi*Fc*t);\n", +" \n", +" x = ((Eb+Ea*sin(2*%pi*Fm*t))).*(sin(2*%pi*Fc*t));\n", +" \n", +" subplot(3,1,2);\n", +" plot2d(t,x);\n", +" title('Amplitude Modulated Signal');\n", +"endfunction\n", +"\n", +"ampmod(Ea,Eb,m,Fc,Fm)//amplitude modulation" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 3.2: Total_power_of_AM_wave.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"clear;\n", +"Pc=300;// Power of the carrier in W\n", +"m=0.6// modulation index\n", +"Pt=Pc*(1+(m^2)/2); //total power\n", +"disp('Total power in the modulated wave(in W) is');\n", +"disp(Pt);" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 3.3_A: Efficiency_of_DSBFC.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"clear;\n", +"disp('efficiency(n)=(useful power/total power)*100%');\n", +"disp(' =total sideband power/(total sideband power+carrier power)*100%');\n", +"\n", +"syms m Pc\n", +"N=[((m^2)*Pc/2)/(Pc*(1+(m^2)/2))];\n", +"disp('*100% ',N);\n", +"\n", +"disp('----------------------------------------------------------------');\n", +"m=0.7 //modulation index\n", +"\n", +"\n", +"n=[m^2/(m^2+2)]*100; //efficiency\n", +"disp(n,'the percentage of useful power is ');" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 3.3: Modulation_index.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"clear;\n", +"Pt=11.5;//Total power in kW\n", +"Pc=10;// Carrier power in kW\n", +"//a)\n", +"\n", +"m_square=2*((Pt/Pc)-1);\n", +"m=sqrt(m_square);//modulation index\n", +"\n", +"//b)\n", +"m2=0.5;\n", +"mt=sqrt(m^2 +m2^2); \n", +"Pt=Pc*(1+mt^2/2); //total power in kW\n", +"\n", +"disp(m,'modulation index is ');\n", +"disp(Pt,'Total carrier power(in kW) ');" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 3.4_A: DSBFC.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"clear;\n", +"Vc=8;// carrier signal voltage in V\n", +"m=1;//modulation index\n", +"R=8;//resistance in ohms\n", +"//a)\n", +"\n", +"Pc=Vc^2/(2*R); \n", +"disp(Pc,'power of the carrier(in W) is');\n", +"Ps=m^2*Pc/4;\n", +"disp(Ps,'Power in each Side-Bands(in W)');\n", +"\n", +"//b)\n", +"disp(2*Ps,'Total sideband Power(in W)');\n", +"\n", +"//c)\n", +"disp(Pc+2*Ps,'Total Power of Modulated wave(in W)');\n", +"\n", +"//d)\n", +"disp(2*Ps/(Pc+2*Ps)*100,'Efficiency Percentage');" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 3.4: Modulation_index_and_power.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"clear;\n", +"m1=0.3;\n", +"m2=0.4;\n", +"m3=0.5;\n", +"m4=0.6; //modulation indices\n", +"Pc=150;//power of carrier in Watts\n", +"\n", +"mt=sqrt(m1^2+m2^2+m3^2+m4^2); //total modulation index\n", +"\n", +"Pt=Pc*(1+mt^2/2);//Total transmitted power in Watts\n", +"\n", +"Ps=(mt^2)*Pc/4; //Sideband Power in Watts\n", +"\n", +"disp(mt,'Total Modulation index');\n", +"\n", +"disp(Pt,'Total Transmitted Power (in W)');\n", +"\n", +"//change in answer as compared to book ,due to approximation error..\n", +"disp(Ps,'Sideband Power(in W)')\n", +"\n", +"\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 3.5_A: Amplitude_Modulatio.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"clear;\n", +"m1=0.3;\n", +"m2=0.4;\n", +"m3=0.5;\n", +"m4=0.6; //modulation indices\n", +"Pc=80;// Power in carrier signal \n", +"\n", +"mt=sqrt(m1^2+m2^2+m3^2+m4^2);\n", +"\n", +"//a)\n", +"disp(mt,'Total Coefficient of Modulation ');\n", +"\n", +"//calculation error in book\n", +"\n", +"//b)\n", +"Ps=(mt^2)*Pc/2;\n", +"disp(Ps,'Sideband powers(in W) ');\n", +"\n", +"//c)\n", +"disp(Pc+2*Ps,'Total Transmitted Power(in W)');\n", +"\n", +"//d)\n", +"disp((Ps/(Pc+2*Ps))*100,'Efficiency Percentage');" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 3.5: Peak_Envelope_Power_and_average_power.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"clear;\n", +"fLSB1=395;\n", +"fLSB22=397.5;// Two LSB frequencies in kHz\n", +"E1=4;\n", +"E2=3;//peak voltages of modulating signal in V\n", +"R=60;//resistor in ohms\n", +"\n", +"Et=sqrt(E1^2+E2^2);\n", +"\n", +"Erms=Et*0.707;\n", +"\n", +"PEP=((Et*0.707)^2)/R; //Pak Envelope Power in W\n", +"\n", +"Avg_Power=PEP/2;\n", +"\n", +"disp(PEP,'Peak Envelope Power(in W)');\n", +"disp(Avg_Power,'Average Power(in W)');" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 3.7_A: Diagonal_Clipping.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"clear;\n", +"Fc=10;//carrier Frequency in kHz\n", +"R=15;//Resistance in Kohms\n", +"C=660;//Capacitance in pF\n", +"a=1/R;\n", +"b=2*%pi*Fc*10^(3)*C*10^(-12);\n", +"Y=a+%i*b;\n", +"Z=1/abs(Y);\n", +"//after rounding off\n", +"Z=12.83//Impedence in Kohms\n", +"m=Z/(R);//modulation index\n", +"disp(m,'MAximum modulation index to avoid diagonal clipping is');" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 3.8_A: Sideband_Frequencies.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"clear;\n", +"\n", +"\n", +"syms Ec Fc Fm pi t\n", +"\n", +"Wave=Ec*cos(2*pi*Fm*t)*cos(2*pi*Fc*t)+Ec*sin(2*pi*Fm*t)*sin(2*pi*Fc*t);\n", +" disp('when the wave is');\n", +" disp(Wave);\n", +"\n", +"f_upper=Ec*cos(2*pi*(Fc+Fm)*t); \n", +"disp('We get the upper sideband as');\n", +"disp(f_upper);\n", +"\n", +"\n", +"f_lower=Ec*cos(2*pi*(Fc-Fm)*t); \n", +"disp('We get the lower sideband as');\n", +"disp(f_lower);\n", +"\n", +"\n", +"\n", +"\n", +"" + ] + } +], +"metadata": { + "kernelspec": { + "display_name": "Scilab", + "language": "scilab", + "name": "scilab" + }, + "language_info": { + "file_extension": ".sce", + "help_links": [ + { + "text": "MetaKernel Magics", + "url": "https://github.com/calysto/metakernel/blob/master/metakernel/magics/README.md" + } + ], + "mimetype": "text/x-octave", + "name": "scilab", + "version": "0.7.1" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/Analog_Communication_by_V_Chandrasekar/4-Angle_Modulation.ipynb b/Analog_Communication_by_V_Chandrasekar/4-Angle_Modulation.ipynb new file mode 100644 index 0000000..76acf6d --- /dev/null +++ b/Analog_Communication_by_V_Chandrasekar/4-Angle_Modulation.ipynb @@ -0,0 +1,614 @@ +{ +"cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Chapter 4: Angle Modulation" + ] + }, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 4.10_A: Angle_Modulation.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"clear;\n", +"\n", +"//f(t)=5cos(Wc*t+3sin(2000*t)+5sin(2000*pi*t))\n", +"\n", +"fm=2000*%pi/(2*%pi); //bandwidth is the highest frequency component\n", +"\n", +"//a)\n", +"\n", +"Freq_dev=(6000+10000*%pi)/(2*%pi);\n", +"\n", +"//b)\n", +"\n", +"B=Freq_dev/fm;\n", +"\n", +"//c)\n", +"Phase_dev=8;//Highest value of[3sin(2000t)+5sin(2000*pi*t)]\n", +"\n", +"//d)\n", +"Bw= 2*(fm+Freq_dev);\n", +"\n", +"disp(Freq_dev,' a) Frequency Deviation(in Hz)=');\n", +"disp(B,' b) Devaition Ratio=');\n", +"disp(Phase_dev,' c) Phase Deviation( in rad)=');\n", +"disp(Bw,' d) Bandwidth( in Hz)=')" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 4.1_A: Frequency_Deviation.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"\n", +"clc;\n", +"clear;\n", +"Freq_dev=6; //Frequency Deviation in kHz\n", +"Vm=3; //Modulating Voltage in V\n", +"\n", +"Dev=Freq_dev*10^(3)/Vm;\n", +"\n", +"// for Vm=6V\n", +"\n", +"Vm=6;\n", +"Freq_dev_new=Dev*Vm;\n", +"\n", +"disp(Freq_dev_new,'the new deviation( in Hz)');" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 4.1: phase_and_frequency_deviation.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"clear;\n", +"\n", +"t=0:0.01:1; \n", +"Freq=2*%pi*10^(5)+3*2*%pi*100*cos(2*%pi*100*(t));//Phase=2*%pi*10^(5)*t+3*sin(2*%pi*100*t);\n", +"\n", +"t1=0.4;// time in ms\n", +"Ang_Freq=2*%pi*10^(5)+3*2*%pi*100*cos(2*%pi*100*(t1*10^(-3)));\n", +"Freq=Ang_Freq/(2*%pi); \n", +"\n", +"//change in answer due to calculation error in book\n", +"disp(Freq,'Instantaneous Frequency(in Hz) at (t=0.4ms)N =');\n", +"\n", +"\n", +"Max_pha_Dev=3; //max(3sin(2*%pi*100t))\n", +"\n", +"disp(Max_pha_Dev,' Maximum Phase Deviation(in rad) =');\n", +" \n", +"Max_fre_Dev=6*%pi*100;//max(6*pi*100*cos(2*pi*100t))\n", +"\n", +"\n", +"\n", +"disp(Max_fre_Dev/(2*%pi),'MAximum Frequency Deiation(in Hz)');" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 4.2_A: Power_in_FM_system.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"clear;\n", +"Wc=8*10^(8);// Angular Frequency of Carrier Signal\n", +"fc=Wc/(2*%pi);\n", +"\n", +"Wm=1300;//Angular Frequency of Message Signal\n", +"fm=Wm/(2*%pi);\n", +"\n", +"B=3;//Modulation Index\n", +"R=12;\n", +"Vc_rms=15/sqrt(2);\n", +"\n", +"Max_dev=B*fm; \n", +"Power=Vc_rms^(2)/R;\n", +"\n", +"disp(Power,'Power Dissipated (in W) is');" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 4.2: Peak_Frequency_Deviation.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"clear;\n", +"a=3;//amplitude in volts\n", +"Dev_sen=4;// deviation sensitivity in KHz/volts\n", +"fm=1.5;// frequency modulating signal in KHz\n", +"\n", +"f=Dev_sen*10^(3)*3;//peak frequency deviation\n", +"B=f/(fm*10^3);\n", +"\n", +"disp(f,'Peak Frequency Deviation( in Hz) ');\n", +"disp(B,'modulation index ');" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 4.3_A: BAndwidth_of_FM.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"clear;\n", +"fm=3; //Modulating Frequency in kHZ\n", +"Max_Dev=18; //MAximum Deviation in kHz\n", +" \n", +" B=Max_Dev/fm; //modulation index\n", +" \n", +" J=12;//from Bessel Table, for B=6\n", +" Bw=fm*J*2*10^(3);\n", +" \n", +" disp(Bw,'The Bandwidth (in Hz) is') ;" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 4.3: Peak_Phase_Deviatio.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"clear;\n", +"Dev_sen=3.5;// Deviation Sensitivity in rad/volt\n", +"a=2.5;// amplitude in volts\n", +"\n", +"B=a*Dev_sen; //Peak Phase Deviation\n", +"\n", +"disp(B,'Peak Phase Deviation( in rad)');" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 4.4_A: Peak_Deviation_in_FM.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"clear;\n", +"Wm=18850;//Angular Frequency of message signal\n", +"fm=Wm/(2*%pi);\n", +"a=3;// amplitude of message signal\n", +"\n", +"Dev_sen=6;//Deviation Sensitivity in kHz/V\n", +"Max_Freq_Dev=a*Dev_sen*10^(3);\n", +"\n", +"B=Max_Freq_Dev/(fm);\n", +"\n", +"disp(Max_Freq_Dev,'Maximum Frequency Deviation(in Hz)');\n", +"disp(B,'Modulation Index');" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 4.4: Frequency_Modulation.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"clear;\n", +"a=3; //amplitude in Volts\n", +"Dev=4;// Deviation in kHz\n", +"fm=1;// modulating frequency in kHz\n", +"\n", +"Dev_sen=Dev*10^(3)/a; //Deviation Sensitivity\n", +"B=Dev/fm; // Modulation Index\n", +"\n", +"disp(Dev_sen,'Deviation Sensitivity(in kHz/V)');\n", +"disp(B,'Modulation Index');\n", +"\n", +"//a)\n", +"a=5;\n", +"Dev_sen_1=a*Dev_sen;\n", +"B=Dev_sen_1/(fm*10^(3));\n", +"\n", +"disp(Dev_sen_1,'Deviation Sensitivity for 5V (in Hz)');\n", +"disp(B,'Modulation index');\n", +"\n", +"\n", +"//b)\n", +"a=10;\n", +"fm=400;\n", +"Dev_sen_2=a*Dev_sen;\n", +"B=Dev_sen_2/fm;\n", +"\n", +"\n", +"disp(Dev_sen_2,'Deviation Sensitivity for 10V (in Hz)');\n", +"disp(B,'Modulation index');" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 4.5_A: side_frequencies_and_Aplitudes.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"clear;\n", +"disp('for B=2, The number of significant frequencies are 6');\n", +"disp('They are J1,J2,J3,J4,J5 and J6');\n", +"disp('Their amplitudes with carriers are');\n", +"J0= 0.224*8;\n", +"J1= 0.577*8;\n", +"J2= 0.353*8;\n", +"J3= 0.129*8;\n", +"J4= 0.034*8;\n", +"J5= 0.007*8;\n", +"J6= 0.001*8;\n", +"disp(J6, J5,J4,J3,J2,J1,J0,'they are (in V)');" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 4.5: CArson_Bandwidth.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"clear;\n", +"fm=3; //Modulating Frequency in kHZ\n", +"Max_dev=15;// Maximum Deviatin in kHZ\n", +"\n", +"B=Max_dev/fm;\n", +"\n", +"J=8; // Bessel table,the highest J coefficient\n", +"BW=J*fm*10^(3);//Bandwidth in kHz\n", +"\n", +"BW1=2*(fm+Max_dev)*10^(3);// According to carson rule, BAndwidth\n", +"\n", +"disp(BW,'Bandwidth required (in Hz)');\n", +"disp(BW1,'According to Carsons rule, Bandwidth(in Hz)');" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 4.6_A: Carson_Bandwidth.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"clear;\n", +"Max_Freq_Dev=12; //Maximum Frequency Deviation in kHZ\n", +"fm=6; //Modulating frquency in kHz\n", +"\n", +"B=Max_Freq_Dev/fm;// Modulation index\n", +"\n", +"J=6;//From Bessel Table, for B=2\n", +"\n", +"Bw=2*J*6*10^(3);\n", +"BW_carson=2*(fm + Max_Freq_Dev)*10^(3);\n", +"\n", +"disp(Bw,' Minimum Bandwidth (in Hz) is');\n", +"disp(BW_carson,' Approximate Minimum Bandwidth according to carson rule( in Hz) is');" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 4.6: Average_Power_of_signal.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"clear;\n", +"a=10; //Amplitude in V\n", +"Pt=a*(0.18^2 +2*(0.33^2 +0.05^2+0.36^2+0.39^2+0.26^2+0.13^2+0.05^2+0.02^2+0.01^2));\n", +"\n", +"disp(' For B=5 from the Bessel table,The Bessel Function is taken upto J9');\n", +"disp(Pt,' Hence the average power of the modulated signal (in W) is');\n", +"disp('Hence, the average power of the modulated signal is equal to ');\n", +"disp('unmodulated carrier power');" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 4.7_A: Unmodulated_Carrier_Power.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"clear;\n", +"a=8;// amplitude in V\n", +"r=30; //resistance in ohms\n", +"\n", +"Pc_unmodulated=a^2/(2*r);\n", +"Pt=1.792^2/(2*30)+2*(4.616)^2/(2*30)+2*(2.824^2)/(2*30)+2*(1.032)^2/(2*30)+2*(0.272)^2/(2*30)+2*(0.056)^2/(2*30)+2*(0.008)^2/(2*30);\n", +"\n", +"// change in answer due to approximations in the book\n", +"\n", +"disp(Pc_unmodulated,'Unmodulated Power Carrier(in W)=');\n", +"disp(Pt,'Total Power in modulated wave(in W)=');\n", +"disp('Power in the modulated wave is equal to');\n", +"disp('power in the unmodulated wave');\n", +"disp('Small error due to rounded off values in Bessel functions');" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 4.7: Phase_Modulatio.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"clear;\n", +"syms t pi;\n", +"\n", +"Pha_dev=3; //Phase_Deviation constant in rad/V\n", +"\n", +"// Phase Modulation Function \n", +"\n", +"Pha_function=Pha_dev*4*sin(2*pi*1.5*10^(3)*t); \n", +"Mod_wave=8*cos(2*pi*10^(4)*t) +Pha_function\n", +"\n", +"disp( Pha_function,'the Phase Modulation Function = ');\n", +"\n", +"disp(Mod_wave ,'The Modulated Wave Function = ');" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 4.8_A: Balanced_Modulator.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"clear;\n", +"\n", +"initial_Freq_Dev=5; //frequency in kHz\n", +"B_initial=0.5; //modulation index\n", +"fm_initial=10;// message signal frequency in kHz\n", +"fc_initial=800; //carrier frequency in kHz\n", +"\n", +"disp('The outputs of the balanced modulator for these parameters');\n", +"disp('are same as the inputs');\n", +"disp('They remain unaltered');\n", +"\n", +"//at the output of the multiplier\n", +"\n", +"m=12;// multiplication factor\n", +"\n", +"final_Freq_Dev=initial_Freq_Dev*m;\n", +"B_final=0.5*m;\n", +"fm_final=10; //modulating signal remains unaltered\n", +"fc_final=800*m;\n", +"\n", +"disp('At the output of the Multiplier,');\n", +"disp(fc_final,'Fc(in kHz)=',fm_final,'Fm(in kHz)=',B_final,'B=');\n", +"disp(final_Freq_Dev,' Frequency Deviation(in kHz)=');" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 4.9_A: Frequency_Deviation.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"clear;\n", +"ft=100.2; //final carrier frequency in MHz\n", +"Freq_Dev_ft=60;// Frequency Deviation in KHz at power amplifier\n", +"fm=10;//modulating frequency in KHz\n", +"m=25;//multiplication factor\n", +"\n", +"//a)\n", +"fc=ft/25;\n", +"\n", +"//b)\n", +"Freq_Dev=Freq_Dev_ft/25;\n", +"\n", +"//c)\n", +"B=Freq_Dev/fm;\n", +"\n", +"//d)\n", +"Bt=B*m;\n", +"\n", +"disp(fc,'a) MAster Oscillator Centre Frequency(in MHz) =');\n", +"disp(Freq_Dev, 'b) Frequency Deviation at the output of modulator(in KHz)=');\n", +"disp(B,'c)Devaition ratio at the output of modulator');\n", +"disp(Bt,'d)deviation ratio at power amplifier');" + ] + } +], +"metadata": { + "kernelspec": { + "display_name": "Scilab", + "language": "scilab", + "name": "scilab" + }, + "language_info": { + "file_extension": ".sce", + "help_links": [ + { + "text": "MetaKernel Magics", + "url": "https://github.com/calysto/metakernel/blob/master/metakernel/magics/README.md" + } + ], + "mimetype": "text/x-octave", + "name": "scilab", + "version": "0.7.1" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/Analog_Communication_by_V_Chandrasekar/5-Pulse_Modulation.ipynb b/Analog_Communication_by_V_Chandrasekar/5-Pulse_Modulation.ipynb new file mode 100644 index 0000000..3a86a54 --- /dev/null +++ b/Analog_Communication_by_V_Chandrasekar/5-Pulse_Modulation.ipynb @@ -0,0 +1,261 @@ +{ +"cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Chapter 5: Pulse Modulation" + ] + }, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 1.A: Sample_and_Hold.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"//('current through the capacitor is i=C(dv/dt)');\n", +"\n", +"t=15; //acquisition time in us\n", +"i=5; //current in mA\n", +"v=5; //maximum voltage across capacitor in V\n", +"\n", +"\n", +"// to satisfy current requirement\n", +"disp('to satisfy current requirement');\n", +"C_current_req=i*t/v;\n", +"disp(C_current_req,'C(nF)=');\n", +"\n", +"//to satisfy accuracy requirement\n", +"disp('to satisfy accuracy requirement');\n", +"\n", +"C_accuracy_req=t/(6.9*15)*1000;// to convert into 'nanoFarad'\n", +"\n", +"disp(C_accuracy_req,'C(nF)=');\n", +"\n", +"disp('to satisfy both requirements,smaller of the two can b taken');\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 5.1: Sampling.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"disp('for 8-KHz sampling,the frequencies present are...(in KHz)');\n", +"\n", +"Fs=8; //sampling frequency\n", +"Fst=3.5 //single tone frequency\n", +"\n", +"disp(Fst);\n", +"disp(-Fst);\n", +"disp(Fs-Fst);\n", +"disp(-(2*Fs+Fst),(2*Fs+Fst),-(Fs+Fst),(Fs+Fst),(Fs-Fst));\n", +"disp('...etc...');\n", +"\n", +"disp('in this case, if the LPF is designed with cut-off frequency(8/2= 4-KHz)');\n", +"disp('then the maximum passable frequency is 3.5-KHz');\n", +"disp('for 5-KHz sampling,the frequencies present are...(in KHz)');\n", +"\n", +"Fs=5;//new sampling frequency\n", +"disp(Fst);\n", +"disp(-Fst);\n", +"disp(Fs-Fst);\n", +"disp(-(2*Fs+Fst),(2*Fs+Fst),-(Fs+Fst),(Fs+Fst),(Fs-Fst));\n", +"disp('...etc...');\n", +"\n", +"disp('in this case, if the LPF is designed with cut-off frequency(5/2=2.5-KHz)');\n", +"disp('then the original signal cant be passed');\n", +"disp('therefore, the signal cant be reconstructed');\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 5.2_A: Aliasing_Frequency.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"clear;\n", +"F_audio=5; //Audio input Frequency in kHz\n", +"\n", +"F_sampling=2*F_audio;\n", +"\n", +"disp(F_sampling,'The Minimum Sampling Frequency (in kHz)');\n", +"\n", +"disp('When the audio Frequency of 6 Khz enters the Sample and Hold circuit');\n", +"disp('it will overlap the audio spectrum, and the alaising frequency is 4 kHz');" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 5.2: Sampling_Rate.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"clear;\n", +"\n", +"//x(t)=2sin(4000*pi*t)+3sin(5000*pi*t)+4sin(8000*pi*t)\n", +"\n", +"fh=8000/2;\n", +"fl=4000/2;\n", +"\n", +"disp(fh,'a) Highest Frequency component(in Hz)');\n", +"disp(fl,'Lowest Frequency component(in Hz)');\n", +"\n", +"fs=2*fh;\n", +"disp(fs,' Minimum Sampling frequency(in Hz)');\n", +"\n", +"Bw=fh-fl;\n", +"disp(Bw,' b)Bandwidth(in Hz) is');\n", +"\n", +"n=fh/Bw;\n", +"disp(n,'integer factor');\n", +"\n", +"Fs_new=2*fh/n;\n", +"disp(Fs_new,'Required Sampling frequency in this case(in Hz) is');\n", +"\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 5.3_A: PCM_system.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"clear;\n", +"fm=5;// maximum analog frequency in kHz\n", +"Min_dyna_range=35;\n", +"Vr=3; //Voltage in the receiver in V\n", +"\n", +"//a)\n", +"F_sampling=2*fm;\n", +"\n", +"//b)\n", +"n=Min_dyna_range/6;\n", +"k=(Vr-(-Vr)+1);// inclusive of sign bit\n", +"\n", +"//c)\n", +"Resolution=Vr/(2^(7));\n", +"\n", +"//d)\n", +"Max_quant_Error=Resolution/2\n", +"\n", +"disp(F_sampling,'a)Minimum Sampling Rate(in kHz) =');\n", +"disp(n,'b) Minimum dynamic Range is');\n", +"disp(' But Closest whole number is 6. Henc,6 bits must be used for amplitude' );\n", +"disp('But the amplitude range is from -3 to +3 V,hence a sign bit also ');\n", +"disp( k,'becomes necessary..Therefore,the total number of bits');\n", +"disp(Resolution,'c) Resolution(in V) =');\n", +"disp(Max_quant_Error,' d)MAximum Quantization Error (in V) ');" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 5.4_A: Bandwidth_of_PCM_system.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"clear;\n", +"n=16;// Number of telephone lines\n", +"m=256;//Quantization levels\n", +"q=8;// since 2^(q)=256\n", +"\n", +"fs=10;//Sampling frequency in kHz\n", +"\n", +"Bw=[(16*9)+1]*10*10^(3);\n", +"\n", +"disp(Bw,'Bandwidth (in Hz ) is');" + ] + } +], +"metadata": { + "kernelspec": { + "display_name": "Scilab", + "language": "scilab", + "name": "scilab" + }, + "language_info": { + "file_extension": ".sce", + "help_links": [ + { + "text": "MetaKernel Magics", + "url": "https://github.com/calysto/metakernel/blob/master/metakernel/magics/README.md" + } + ], + "mimetype": "text/x-octave", + "name": "scilab", + "version": "0.7.1" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/Analog_Communication_by_V_Chandrasekar/6-Noise.ipynb b/Analog_Communication_by_V_Chandrasekar/6-Noise.ipynb new file mode 100644 index 0000000..96ab766 --- /dev/null +++ b/Analog_Communication_by_V_Chandrasekar/6-Noise.ipynb @@ -0,0 +1,545 @@ +{ +"cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Chapter 6: Noise" + ] + }, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 6.1: Thermal_Noise.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"T=290; // temperature in kelvin\n", +"k=1.38*10^(-23); // Boltzman constant\n", +"B=1;// bandwidth in MHz\n", +"\n", +"P=k*T*B*10^(6); // thermal noise power\n", +"disp('the thermal noise power (in watts) is ');\n", +"disp(P);" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 6.2_A: SNR_and_Noise_Figure.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"clear;\n", +"\n", +"Inp_sig_pow=1.5*10^(-9); //Input Signal Power in Watts\n", +"Inp_noi_pow=1.5*10^(-18); //Input Noise Power in Watts\n", +"Pow_gain=10^(6);\n", +"int_noi=4*10^(-12); //internal noise in watts\n", +"\n", +"//a)\n", +"Inp_SNR=10*log10(Inp_sig_pow/Inp_noi_pow);// input SNR in dB\n", +"\n", +"//b)\n", +"Nout=Pow_gain*Inp_noi_pow+int_noi //output output noise power\n", +"\n", +"Pout=Pow_gain*Inp_sig_pow //output signal power\n", +"\n", +"SNR=Pout/Nout;// Signal to Noise ratio\n", +"SNRout=10*log10(SNR);// Output SNR in dB\n", +"\n", +"//c)\n", +"F=10^(9)/(273*10^(6)); //Noise factor\n", +"NF=10*log10(F);// Noise figure in dB\n", +"\n", +"disp('Input SNR (in dB) is');\n", +"disp(Inp_SNR);\n", +"disp('Output SNR ( in dB) is');\n", +"disp(SNRout);\n", +"disp('Noise factor');\n", +"disp(F);\n", +"disp('Noise Figure(in dB)');\n", +"disp(NF);" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 6.2: Noise_voltage.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"clear;\n", +"T=290;// temperature in kelvin\n", +"R=60;//resistance in ohms\n", +"k=1.38*10^(-23);\n", +"\n", +"Esquare=4*R*T*k;\n", +"E=sqrt(Esquare); //noise voltage\n", +"\n", +"disp('the noise voltage( in volts) is')\n", +"disp(E);" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 6.3_A: Noise_Voltage.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"clear;\n", +"q=1.6*10^(-19);// electron charge\n", +"Ieq=5;//equivalent shot noise current in uA\n", +"Bn=8;//bandwidth in MHz\n", +"Rn=200;\n", +"Rs=100;//resistance in ohms\n", +"k=1.38*10^(-23);// boltzman constant\n", +"T=290;//temperature in K\n", +"Vs=10// RMS signal source volatage in uV\n", +"\n", +"In=sqrt(2*Ieq*q*Bn);\n", +"\n", +"Vni=Rs*In;//shot noise voltage \n", +"\n", +"Vns=sqrt(4*Rs*k*T*Bn*10^(6));//thermal noise volatge from source\n", +"\n", +"//change in answer due to calculation error in book \n", +"Vne=sqrt(4*Rn*k*T*Bn*10^(6));//noise voltage by equivalent noise resistance\n", +"\n", +"Vn=sqrt(Vni^2+Vns^2+Vne^2);// total noise voltage\n", +"\n", +"SNR=20*log10(Vs*10^(-6)/Vn);\n", +"\n", +"disp('shot noise voltage(in V) is ');\n", +"disp(Vni);\n", +"disp('thermal noise voltage from source(in V) is');\n", +"disp(Vns);\n", +"disp('noise voltage by equivalent noise resistance(in V) is');\n", +"disp(Vne);\n", +"disp('total noise voltage at the input(in V) is');\n", +"disp(Vn);\n", +"disp('SNR (in dB) is');\n", +"disp(SNR);\n", +"\n", +"\n", +"\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 6.3: Thermal_Noise_Voltage.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"B=150;// bandwidth in KHz\n", +"R1=30;\n", +"R2=60;// both resistors R1 and R2 in K-ohms\n", +"k=1.38*10^(-23);// boltzman constant\n", +"T=290; //temperature in Kelvin\n", +"\n", +"Esquare=4*R1*10^(3)*k*B*10^(3)*T;\n", +"E=sqrt(Esquare);\n", +" \n", +"disp('series combination Rseries(in K-ohms)=');\n", +"disp(R1+R2);\n", +"Eseries=E*sqrt(3);\n", +"disp('the thermal noise voltage (in volts) is');\n", +"disp(Eseries);\n", +"\n", +"disp('series combination Rseries(in K-ohms)=');\n", +"disp(R1*R2/(R1+R2));\n", +"Eparallel=E*sqrt(2/3);\n", +"disp('the thermal noise voltage (in volts) is');\n", +"disp(Eparallel);" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 6.4_A: Output_SNR.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"clear;\n", +"S=4;//number of stages\n", +"SNR_input=55;//input Signal to Noise ratio in dB\n", +"\n", +"SNR_output=SNR_input-10*log10(S);\n", +"\n", +"disp('Output SNR( in dB) is');\n", +"disp(SNR_output);" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 6.4: Shot_Noise.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"clear;\n", +"\n", +"Idc=2; //direct current in mA \n", +"q=1.6*10^(-19); // electron charge\n", +"B=3; //bandwidth in MHz\n", +"\n", +"Isquare=2*Idc*10^(-3)*q*B*10^6;\n", +"I=sqrt(Isquare); //shot noise component\n", +"\n", +"disp('the shot noise component(in amperes) is');\n", +"disp(I);\n", +" " + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 6.5_A: Output_SNR.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"clear;\n", +"F=5; //noise figure in dB\n", +"SNR_input=55;//Input Signal to noise ratio in dB\n", +"SNR_output=SNR_input-F;\n", +"disp('Output SNR (in dB) is');\n", +"disp(SNR_output);" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 6.5: Output_SNR.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"clear;\n", +"Np1=60; // Noise-Power ratio of first system in dB\n", +"Np2=40; // Noise-Power ratio of second system in dB\n", +"Np3=30; // Noise-Power ratio of third system in dB\n", +"Np4=50; // Noise-Power ratio of fourth system in dB\n", +" \n", +" P1=10^(-6); //power ratio of first system\n", +" P2=10^(-4); //power ratio of second system\n", +" P3=10^(-3); //power ratio of third system\n", +" P4=10^(-5);//power ratio of fourth system\n", +" \n", +" SNR=(P1+P2+P3+P4); // Overall Signal to Noise ratio\n", +" disp('SNR ratio is');\n", +" disp(SNR);\n", +" \n", +" N_final=30; //since SNR is 10^(-3)\n", +" \n", +" disp('overall SNR (in dB)is');\n", +" disp(N_final);\n", +" \n", +" disp('the overall SNR is equal to that of the worst system')\n", +" " + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 6.6_A: Noise_Figure.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"clear;\n", +"F=16;// Power ratio in dB\n", +"k=1.38*10^(-23) ;// boltzman constant\n", +"T=290; //temperature in K\n", +"B=5; //Bandwidth in MHz\n", +"\n", +"P=(F-1)*k*T*B*10^(6);\n", +"disp(' Amplifier Inout noise power (in watts) is');\n", +"disp(P);\n", +" " + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 6.6: Output_SNR.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"clear;\n", +"N_figure=8 ;//Noise figure in dB\n", +"SNR_in=45; //Signal to Noise ratio in dB\n", +"\n", +"SNR_out=SNR_in-N_figure //output Signal to Noise ratio\n", +"\n", +"disp('the Output SNR(in dB) is ');\n", +"disp(SNR_out);" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 6.7_A: Overall_noise_figure.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"clear;\n", +"Nf1=7; //Noise figure of first stage in dB\n", +"F1=5.01; //first power ratio\n", +"Nf2=25; //Noise figure of second stage in dB\n", +"F2=316.22; //second power ratio\n", +"pG=15; //power gain in dB\n", +"G1=31.62; //power ratio\n", +"\n", +"F=F1+(F2-1)/G1;\n", +"\n", +"disp('overall noise factor');\n", +"disp(F);\n", +"disp('Overall noise factor in dB')\n", +"disp(10*log10(F)); " + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 6.8_A: Noise_Temperature.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"clear;\n", +"Nf=15; //noise figure in dB\n", +"F=31.62;//power ratio\n", +"T=290; //Temperature in K\n", +"T_em=(F-1)*T\n", +"\n", +"G1=10^(6); //power ratio\n", +"N_t=80; //Noise temperature in K\n", +"T_e=N_t+T_em/G1;\n", +"\n", +"disp('Noise temperature of receiver (in K)');\n", +"disp(T_em);\n", +"\n", +"// change in answer....the calculation in the book is wrong\n", +"\n", +"disp('Overall Noise temperature of receiving system(in K) is');\n", +"disp(T_e);" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 6.9_A: Noise_Temperature.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"clear;\n", +"ENR=31.62; //10^(1.5);\n", +"Y=6.30; //10^(0.8)\n", +"T=290;//temperature in K\n", +"T_h=T*(ENR+1);\n", +"\n", +"T_e=(T_h-Y*(T))/(Y-1);\n", +"disp('Equivalent Noise Temperature (in K) is');\n", +"disp(T_e);" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 6.A: Thermal_Noise_Power.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"clear;\n", +"T=290;//Temperature in K\n", +"B=15; //Bandwidth in KHz\n", +"k=1.38*10^(-23); //Boltzman constant\n", +"R=60; //resistance in ohms\n", +"\n", +"N=k*T*B*10^(3); //Therman Noise Power in watts\n", +"N_dBm=10*log10(N/0.001);//in dBm\n", +"\n", +"Vrms=sqrt(4*R*k*T*B*10^(3));\n", +"\n", +"disp('thermal noise power (in watts) is');\n", +"disp(N);\n", +"disp('thermal noise power (in dBm) is');\n", +"disp(N_dBm);\n", +"disp('RMS noise voltage (in Volts) is');\n", +"disp(Vrms);" + ] + } +], +"metadata": { + "kernelspec": { + "display_name": "Scilab", + "language": "scilab", + "name": "scilab" + }, + "language_info": { + "file_extension": ".sce", + "help_links": [ + { + "text": "MetaKernel Magics", + "url": "https://github.com/calysto/metakernel/blob/master/metakernel/magics/README.md" + } + ], + "mimetype": "text/x-octave", + "name": "scilab", + "version": "0.7.1" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/Analog_Communication_by_V_Chandrasekar/7-Introduction_to_Digital_Communication_.ipynb b/Analog_Communication_by_V_Chandrasekar/7-Introduction_to_Digital_Communication_.ipynb new file mode 100644 index 0000000..94546b6 --- /dev/null +++ b/Analog_Communication_by_V_Chandrasekar/7-Introduction_to_Digital_Communication_.ipynb @@ -0,0 +1,249 @@ +{ +"cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Chapter 7: Introduction to Digital Communication " + ] + }, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 7.1_A: Baud_Rate_and_Bandwidth.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"clear;\n", +"bin_signal=20; //binary signal in kbps\n", +"N=1;//since ASK\n", +"\n", +"Bw=bin_signal*10^(3);\n", +"Baud=bin_signal*10^(3);\n", +"\n", +"disp(Bw,'Bandwidth(in Hz)=');\n", +"disp(Baud,'Baud rate=');" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 7.1: Baud_Rate.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"clear;\n", +"N=1;// since ASK\n", +"Bin_Sig=15;//Binary signal in kbps\n", +"\n", +"BW=Bin_Sig*10^(3)/N;\n", +"Baud=Bin_Sig*10^(3)/N;\n", +"disp(BW,'Bw=');\n", +"disp(Baud,'Baud=');" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 7.2_A: Bandwidth_and_Baud_Rate.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"clear;\n", +"mark_f=59;//MArk Frequency in Hz\n", +"space_f=61; //space frequency in Hz\n", +"input_rate=5;//input rate in kbps\n", +"\n", +"Peak_Frq_Dev=abs((mark_f-space_f)/2);\n", +"Bw=2*(Peak_Frq_Dev+input_rate)*10^(3);\n", +"baud=input_rate*10^(3);\n", +"\n", +"disp(Peak_Frq_Dev,'Peak Frequency Deviation (in KHz) =');\n", +"disp(Bw,'Minimum BW (in Hz)=');\n", +"disp(baud,'Baud=');" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 7.2: Baud_Rate_and_Bandwidth.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"clear;\n", +"mark_f=60;//Mark Frequency in KHz\n", +"space_f=63;//Space Frequency in KHz\n", +"input_bit_rate=3;// input bit rate\n", +"\n", +"Peak_Frq_Dev=abs((mark_f-space_f)/2);\n", +"B=2*(Peak_Frq_Dev+input_bit_rate);\n", +"Baud=input_bit_rate*10^(3);\n", +"\n", +"disp(Peak_Frq_Dev,'Peak Frequency Deviation(in KHz)=');\n", +"disp(B,'Minimum Bandwidth(in KHz)=');\n", +"disp(Baud,'Baud rate=');" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 7.3_A: Bandwidth_and_Baud_Rate.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"clear;\n", +"N=3;// since 8-PSK\n", +"bit_rate=36;// in kbps\n", +"\n", +"Bw=bit_rate*10^(3)/N;\n", +"baud=bit_rate*10^(3)/N;\n", +"n=bit_rate*10^(3)/Bw;\n", +"\n", +"disp(Bw,' Minimum Bandwidth(in Hz)=');\n", +"disp(baud,'Baud rate=');\n", +"disp(n,'Bandwidth efficiency(in bits per second per cycle of bandwidth)=');" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 7.3: Baud_Rate_and_Bandwidth.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"clear;\n", +"bit_rate=36;// information bit rate in Kbps\n", +"m=3;// since 8-PSK\n", +"\n", +"Baud=bit_rate*10^(3)/m;\n", +"Bw=36*10^(3)/m;\n", +"n=36000/12000;\n", +"\n", +"disp(Baud,'Baud=');\n", +"disp(Bw,'BW=');\n", +"disp(n,'Bandwidth efficiency(in bits/cycle)=');" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 7.4_A: Nyquist_Bandwidth.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"clear;\n", +"\n", +"Input_bit=5; //Input bit rate in Mbps\n", +"\n", +"//bit rate in I,Q,C channels is one-third of input bit rate\n", +"\n", +"fbI=Input_bit/3;//bit rate in I channel\n", +"fbC=Input_bit/3;//bit rate in C channel\n", +"fbQ=Input_bit/3;////bit rate in I channel\n", +"\n", +"Baud=fbI;//Baud in Mbps\n", +"\n", +"fa=fbC/2;\n", +"\n", +"//Output from Modulator is \n", +"// 0.5cos(2*pi*49.17MHz)-0.5cos(2*pi*50.83MHz)\n", +"\n", +"Nyquist=50.83-49.17;\n", +"\n", +"disp(Nyquist,'Minimum Nyquist Bandwidth(in MHz)=');\n", +"\n", +"" + ] + } +], +"metadata": { + "kernelspec": { + "display_name": "Scilab", + "language": "scilab", + "name": "scilab" + }, + "language_info": { + "file_extension": ".sce", + "help_links": [ + { + "text": "MetaKernel Magics", + "url": "https://github.com/calysto/metakernel/blob/master/metakernel/magics/README.md" + } + ], + "mimetype": "text/x-octave", + "name": "scilab", + "version": "0.7.1" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/Analog_Communication_by_V_Chandrasekar/8-Information_theory.ipynb b/Analog_Communication_by_V_Chandrasekar/8-Information_theory.ipynb new file mode 100644 index 0000000..ba5f8a1 --- /dev/null +++ b/Analog_Communication_by_V_Chandrasekar/8-Information_theory.ipynb @@ -0,0 +1,312 @@ +{ +"cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Chapter 8: Information theory" + ] + }, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 8.10_A: SNR.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"clear;\n", +"W=3000;\n", +"SNR_db=39;// 10log (SNR_ratio)=SRN_db\n", +"SNR_ratio=7943; //10^(3.9)\n", +"\n", +"C=W*log2(1+SNR_ratio);\n", +"\n", +"disp(C,'Capacity (in bits/s) =');" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 8.1_A: Information_Rate.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"clear;\n", +"p1=1/8;\n", +"p2=1/8;\n", +"p3=5/8;\n", +"p4=1/8; //Quantization Levels\n", +"//B is the Bandwidth of the signal\n", +"\n", +"H=p1*log2(1/p1)+p2*log2(1/p2)+p3*log2(1/p3)+p4*log2(1/p4);\n", +"\n", +"disp(H,'The average Information (in bits/message)=');\n", +"disp('The Information Rate R=rH =2*B(1.55) =3.1B bits/s');" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 8.2_A: ShannonFano_and_Huffman_coding.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"clear;\n", +"m1=0.2;\n", +"m2=0.3;\n", +"m3=0.2;\n", +"m4=0.15;\n", +"m5=0.15; // probability of 5 source messages \n", +"\n", +"H=m1*log2(1/m1)+m2*log2(1/m2)+m3*log2(1/m3)+m4*log2(1/m4)+m5*log2(1/m5);//Average information in bits\n", +"\n", +"//a) Shannon-fano coding\n", +" //coding\n", +"// m1 0.2 0 0 00\n", +"// m2 0.3 0 1 01\n", +"// m3 0.2 1 0 10\n", +"// m4 0.15 1 1 0 110\n", +"// m5 0.15 1 1 1 111\n", +"\n", +"L=(0.2*2)+(.3*2)+(0.2*2)+(2*0.15*3) //Average code word length(in bits)=probability *coding length\n", +"\n", +"n=H/L; \n", +"\n", +"disp(n*100,'Coding efficiency for Shannon Fano coding is');\n", +"\n", +"//b) Huffman coding\n", +"\n", +"// m1 0.2 01\n", +"// m2 0.3 00 \n", +"// m3 0.2 11\n", +"// m4 0.15 010\n", +"// m5 0.15 110\n", +"\n", +"L=(0.2*2)+(.3*2)+(0.2*2)+(2*0.15*3) //Average code word length(in bits)=probability *coding length\n", +"\n", +"n=H/L;\n", +"\n", +"disp(n*100,'Coding efficiency for Huffman coding is');\n", +"\n", +"//change in answer due to rounded off value in text-book" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 8.3_A: Gaussian_Channel.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"clear;\n", +"\n", +"PSD=10^(-9); //noise PSD in W/Hz\n", +"Bw=4000;//Wandwidth in Hz\n", +"\n", +"//a) \n", +"E=0.1 //Energy in Joules\n", +"C=Bw*log2(1+E/(2*PSD*Bw));\n", +"disp(C,'a) Capacity of the gaussian channel(in bits/s) when E is 0.1J=');\n", +"\n", +"//b) \n", +"E=0.001 //Energy in Joules\n", +"C=Bw*log2(1+E/(2*PSD*Bw));\n", +"disp(C,'b) Capacity of the gaussian channel(in bits/s) when E is 0.001J=');\n", +"\n", +"//c)\n", +"Bw=10000;\n", +"C=Bw*log2(1+E/(2*PSD*Bw));\n", +"disp(C,'d) Capacity of the gaussian channel(in bits/s) when Bw is 10Khz=');\n", +"\n", +"disp('100 times fall in Energy when the BW is increased by 2.5 times');" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 8.5_A: Throughput_efficiency.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"clear;\n", +"k=973;\n", +"n=1023;\n", +"Pa=0.99;\n", +"Tw=10*10^(-6);\n", +"Tl=40*10^(-6);\n", +"N=4;\n", +"\n", +"N_sw=(k/n)*(Pa/(1+Tl/Tw));// efficiency of stop and wait algorithm\n", +"N_sgpull=(k/n)*(1/(1+N*(1-Pa)/Pa));//efficiency of go-back-N algorithm\n", +"Nsr=(k/n)*Pa;// efficiency of selective repeat algorithm\n", +"\n", +"disp(N_sw,'N s&w');\n", +"disp(N_sgpull,'Nsgpull');\n", +"disp(Nsr,'Nsr');" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 8.6_A: Rate_of_source.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"clear;\n", +"p1=1/2;\n", +"p2=1/4;\n", +"p3=1/8;\n", +"p4=1/16;\n", +"p5=1/16;// probabilities\n", +"\n", +"H=p1*log2(1/p1)+p2*log2(1/p2)+p3*log2(1/p3)+p4*log2(1/p4)+p5*log2(1/p5);\n", +"Bw=4000; //Bandwidth in Hz\n", +"R=2*H*Bw ;\n", +"\n", +"disp(R,'Rate of the source ( in bits/s) is');" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 8.7_A: entropy_of_equiprobable_source.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"clear;\n", +"\n", +"// probability of all the events are same\n", +"syms N;\n", +"\n", +"H_X=N*[(-1/N)*log(1/N)]; //H(X)=(-1/N)log(1/N)+(-1/N)log(1/N)+....N times\n", +"\n", +"disp(H_X,'H(X)=');" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 8.8_A: Self_Information.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"clear;\n", +"P0=2/3; //P(X=0)\n", +"P1=2/3; //P(Y=0)\n", +"H_x=0.919;\n", +"H_y=0.919;\n", +"H_b=0.919; //Hb(2/3)\n", +"\n", +"//since X,Y pair is uniformly distributed on three values\n", +"H_xy=log2(3); // H(X,Y)\n", +"\n", +"H_xdivy=H_xy-H_y; //H(X/Y)=H(X,Y)-H(Y)\n", +"I_xdivy=H_x-H_xdivy; //I(X,Y)=H(X)-H(X/Y)\n", +"\n", +"disp(I_xdivy,'I(X,Y)=');\n", +"\n", +"" + ] + } +], +"metadata": { + "kernelspec": { + "display_name": "Scilab", + "language": "scilab", + "name": "scilab" + }, + "language_info": { + "file_extension": ".sce", + "help_links": [ + { + "text": "MetaKernel Magics", + "url": "https://github.com/calysto/metakernel/blob/master/metakernel/magics/README.md" + } + ], + "mimetype": "text/x-octave", + "name": "scilab", + "version": "0.7.1" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/Analog_Communication_by_V_Chandrasekar/9-Introduction_to_Probability_Random_variable_and_Random_processes.ipynb b/Analog_Communication_by_V_Chandrasekar/9-Introduction_to_Probability_Random_variable_and_Random_processes.ipynb new file mode 100644 index 0000000..04c5874 --- /dev/null +++ b/Analog_Communication_by_V_Chandrasekar/9-Introduction_to_Probability_Random_variable_and_Random_processes.ipynb @@ -0,0 +1,271 @@ +{ +"cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Chapter 9: Introduction to Probability Random variable and Random processes" + ] + }, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 9.1_A: Multiplication_Theoram.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"clear;\n", +"\n", +"P_white=5/8; //P(ball is white)\n", +"\n", +"//white ball is removed,the remaining balls are four white and three green\n", +"\n", +"P_green=3/7; //P(ball is green)\n", +"\n", +"P_tot=P_white*P_green;\n", +"\n", +"disp(P_tot,' Desired Probability using multiplication theoram=')" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 9.1: Conditional_Probability.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clear;\n", +"clc;\n", +"// f2 be the event that ' a two occurs'\n", +"\n", +"\n", +"tot=6; //total number of possible outcomes\n", +"f_2=1; // number of desired outcomes\n", +"M=3; // number of even outcomes\n", +"\n", +"///// a)\n", +"\n", +"P_A=f_2/tot; //P(A)\n", +"\n", +"///// b)\n", +"P_M=M/tot; //P(M)\n", +"\n", +"////// c)\n", +"P_AintersectionM=P_A/P_M; //P(A intersection M)\n", +"\n", +"disp(P_A,'a) P(A)= ');\n", +"disp(P_M,'b) P(M)=');\n", +"disp(P_AintersectionM=P_A/P_M,'c) P(A intersection M)=');\n", +"" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 9.2_A: Theoram_of_Total_Probability.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"clear;\n", +"P_box1=0.25; //P(box1)\n", +"P_box2=0.25; //P(box2)\n", +"P_box3=0.25; //P(box3)\n", +"P_box4=0.25; //P(box4)\n", +"\n", +"Pdef_1=0.05; //P(defective/box1)\n", +"Pdef_2=0.3; //P(defective/box2)\n", +"Pdef_3=0.10; //P(defective/box3)\n", +"Pdef_4=0.20; //P(defective/box4)\n", +"\n", +"\n", +"Pcomp_def=(P_box1*Pdef_1)+(P_box2*Pdef_2)+(P_box3*Pdef_3)+(P_box4*Pdef_4); //Theoram of total probability\n", +"\n", +"disp(Pcomp_def,' P(component is defective)=');" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 9.2: Conditional_Probability.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"clear;\n", +"\n", +"white_ball=3;\n", +"red_ball=2;\n", +"total=white_ball+red_ball;\n", +"P_W=white_ball/total;\n", +"\n", +"P_SRFW=1/2; //Prob. of second red given first white\n", +"\n", +"P_FWSR=P_W *P_SRFW// prob. of first white and second red\n", +"\n", +"disp(P_FWSR,' P(First Ball is White and second is red)=');" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 9.3_A: Error_Probability.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"clear;\n", +"\n", +"P_1=0.3; //P( 1 is transmitted)\n", +"Pe_1=10^(-3); //P(detecting an error when 1 is transmitted)\n", +"P_0=0.7;//P( 0 is transmitted)\n", +"Pe_0=10^(-7); //P(detecting an error when 0 is transmitted)\n", +"\n", +"error_prob=P_1*Pe_1+P_0*Pe_0;\n", +"\n", +"disp(error_prob,'Error Probabillity of the channel');" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 9.3: Bayes_Theoram.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"clear;\n", +"P_box1=0.25; //P(box1)\n", +"P_box2=0.25; //P(box2)\n", +"P_box3=0.25; //P(box3)\n", +"P_box4=0.25; //P(box4)\n", +"\n", +"Pdef_1=0.05; //P(defective/box1)\n", +"Pdef_2=0.4; //P(defective/box2)\n", +"Pdef_3=0.10; //P(defective/box3)\n", +"Pdef_4=0.10; //P(defective/box4)\n", +"\n", +"//a)\n", +"\n", +"Pcomp_def=(P_box1*Pdef_1)+(P_box2*Pdef_2)+(P_box3*Pdef_3)+(P_box4*Pdef_4); //Theoram of total probability\n", +"\n", +"//b)\n", +"Pbox2_def=(P_box2*Pdef_2)/((P_box1*Pdef_1)+(P_box2*Pdef_2)+(P_box3*Pdef_3)+(P_box4*Pdef_4)); //Bayes theoram\n", +"\n", +"disp(Pcomp_def,' a) P(component is defective)=');\n", +"\n", +"disp(Pbox2_def,' b) P(box2|defective)=');" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 9.4_A: Density_Function.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"clc;\n", +"clear;\n", +"//Y is a Gaussian Random Variable\n", +"\n", +"syms y;\n", +"\n", +"x=5;\n", +"m=-3*(x)+5; //mean\n", +"disp(m,'mean');\n", +"\n", +"var=4*7; //variance\n", +"disp(var,'variance');\n", +"\n", +"Y=exp(-{(y+10)^2}/56)/sqrt(56*%pi);\n", +"\n", +"disp('Y is an N{-10,28} random variable');\n", +"disp(Y,'density function f(y)= ');" + ] + } +], +"metadata": { + "kernelspec": { + "display_name": "Scilab", + "language": "scilab", + "name": "scilab" + }, + "language_info": { + "file_extension": ".sce", + "help_links": [ + { + "text": "MetaKernel Magics", + "url": "https://github.com/calysto/metakernel/blob/master/metakernel/magics/README.md" + } + ], + "mimetype": "text/x-octave", + "name": "scilab", + "version": "0.7.1" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} |