diff options
Diffstat (limited to '2303')
41 files changed, 1073 insertions, 0 deletions
diff --git a/2303/CH1/EX1.4/EX_1_4.png b/2303/CH1/EX1.4/EX_1_4.png Binary files differnew file mode 100755 index 000000000..31eaee0c1 --- /dev/null +++ b/2303/CH1/EX1.4/EX_1_4.png diff --git a/2303/CH1/EX1.4/EX_1_4.sce b/2303/CH1/EX1.4/EX_1_4.sce new file mode 100755 index 000000000..359deb746 --- /dev/null +++ b/2303/CH1/EX1.4/EX_1_4.sce @@ -0,0 +1,12 @@ +//Example 1 4
+clc ;
+clear;
+close;
+f=9; //assuming frequency to be a constant 9Hz.
+t =0:.01:10;
+x= cos (2* %pi *f*t);
+plot (t,x);
+xlabel('Time');
+ylabel('Amplitude');
+title('Plot of given sequence to test periodicity');
+disp ( 'Plotting the signal and showing that it is periodic with period=1/f' );
diff --git a/2303/CH1/EX1.5/EX_1_5.png b/2303/CH1/EX1.5/EX_1_5.png Binary files differnew file mode 100755 index 000000000..5bdb86562 --- /dev/null +++ b/2303/CH1/EX1.5/EX_1_5.png diff --git a/2303/CH1/EX1.5/EX_1_5.sce b/2303/CH1/EX1.5/EX_1_5.sce new file mode 100755 index 000000000..0c6025d63 --- /dev/null +++ b/2303/CH1/EX1.5/EX_1_5.sce @@ -0,0 +1,13 @@ +//Example 1 5
+clc ;
+clear;
+close;
+f=9; //assuming frequency to be a constant 9Hz.
+t =0:.1:10;
+x1= cos (2* %pi *f*t);
+x2=t+x1;
+plot (t,x2);
+xlabel('Time');
+ylabel('Amplitude');
+title('Plot of given sequence to test periodicity');
+disp ( 'Plotting the signal and showing that it is APERIODIC' );
diff --git a/2303/CH1/EX1.6/EX_1_6.sce b/2303/CH1/EX1.6/EX_1_6.sce new file mode 100755 index 000000000..2b34bd895 --- /dev/null +++ b/2303/CH1/EX1.6/EX_1_6.sce @@ -0,0 +1,9 @@ +//Example 1 6
+clc ;
+clear;
+close;
+f=9; //assuming frequency to be a constant 9Hz.
+t =0:.1:10;
+x= t+sin(4*180*f*t)+cos(2*180*f*t);
+disp(x);
+disp('Since value of the signal at any time t is known, it is a DETERMINISTIC signal');
diff --git a/2303/CH1/EX1.7/EX_1_7.sce b/2303/CH1/EX1.7/EX_1_7.sce new file mode 100755 index 000000000..3b3e2ea59 --- /dev/null +++ b/2303/CH1/EX1.7/EX_1_7.sce @@ -0,0 +1,11 @@ +//Example 1.7
+clc;
+clear;
+close;
+t =0:0.01:10
+F=1000;
+x=sin(2*%pi*F*t);
+
+P={integrate('(sin(2*180*F*t)^2)','t',-0.001,+0.001)}/(2*1/F);
+disp(P,"Power of signal= ");
+disp("Since the given signal has a finite power, it is a POWER signal");
diff --git a/2303/CH1/EX1.8/EX_1_8.sce b/2303/CH1/EX1.8/EX_1_8.sce new file mode 100755 index 000000000..12c8b9010 --- /dev/null +++ b/2303/CH1/EX1.8/EX_1_8.sce @@ -0,0 +1,10 @@ +//Example 1.8
+clc;
+clear;
+close;
+t =0:0.001:0.5
+x=sin(2*%pi*100*t);
+
+E=integrate('(sin(2*%pi*100*t)^2)','t',-0.01,+0.01);
+disp(E,"Energy of signal= ");
+disp("Since the given signal has a finite energy, it is a ENERGY signal");
diff --git a/2303/CH10/EX10.1/10_1.sce b/2303/CH10/EX10.1/10_1.sce new file mode 100755 index 000000000..7b61735e4 --- /dev/null +++ b/2303/CH10/EX10.1/10_1.sce @@ -0,0 +1,35 @@ +//Example 10.1
+
+clc;
+close;
+clear;
+fx=8000; //sampling frequency of original signal
+
+//Plotting original sequence
+for f=1:1024
+ original(f)=sin(2*180*f/(fx/2));
+end
+subplot(2,1,1);
+plot2d3(original);
+title('Original sequence');
+xlabel('Frequency');
+ylabel('Amplitude');
+
+df=2; //decimation factor
+decimated=[];
+n=1;
+
+//Decimation
+for i=1:length(original)
+ if modulo(i,df)~=0
+ decimated(n)=original(i);
+ n=n+1;
+ end
+end
+
+//Plotting decimated sequence
+subplot(2,1,2);
+plot2d3(decimated);
+title('Decimatated sequence');
+xlabel('Frequency');
+ylabel('Amplitude');
diff --git a/2303/CH10/EX10.1/Decimated_result.png b/2303/CH10/EX10.1/Decimated_result.png Binary files differnew file mode 100755 index 000000000..37ac62f3e --- /dev/null +++ b/2303/CH10/EX10.1/Decimated_result.png diff --git a/2303/CH10/EX10.2/10_2.sce b/2303/CH10/EX10.2/10_2.sce new file mode 100755 index 000000000..a74e08cfb --- /dev/null +++ b/2303/CH10/EX10.2/10_2.sce @@ -0,0 +1,31 @@ +//Example 10.2
+
+clc;
+close;
+clear;
+fx=16000; //sampling frequency of original signal
+
+//Plotting original sequence
+for f=1:1024
+ original(f)=sin(2*180*f/(fx/2));
+end
+subplot(2,1,1);
+plot2d3(original);
+title('Original sequence');
+xlabel('Frequency');
+ylabel('Amplitude');
+
+intf=2; //interpolation factor
+interpolated=[];
+
+//Interpolation
+for i=0:length(original)-1
+ interpolated(intf*i+1,1)=original(i+1);
+end
+
+//Plotting interpolated sequence
+subplot(2,1,2);
+plot2d3(interpolated);
+title('Interpolated sequence');
+xlabel('Frequency');
+ylabel('Amplitude');
diff --git a/2303/CH10/EX10.2/Interpolated_result.png b/2303/CH10/EX10.2/Interpolated_result.png Binary files differnew file mode 100755 index 000000000..b50eb1d82 --- /dev/null +++ b/2303/CH10/EX10.2/Interpolated_result.png diff --git a/2303/CH10/EX10.3/10_3.sce b/2303/CH10/EX10.3/10_3.sce new file mode 100755 index 000000000..3d347abd7 --- /dev/null +++ b/2303/CH10/EX10.3/10_3.sce @@ -0,0 +1,35 @@ +//Example 10.3
+
+clc;
+clear;
+close;
+
+fs1=2048000; //original signal sampling frequency
+fs2=64000; //new sampling frequency
+df=32; //decimation factor of filter
+fp=30000; //pass band edge frequency
+fs=32000; //stop band edge freqeucny
+tw=2000; //transition width
+pbdev=0.01; //pass band deviation in decibel
+sbatt=80; //stop band attenuation in decibel
+
+//Calculating delta-f
+df=tw/fs1;
+//Calculating passband and stop band deviations
+dp=10^(pbdev/20)-1;
+ds=10^-(sbatt/20);
+
+//filter coefficients required for order of filter
+a1=0.005309;
+a2=0.07114;
+a3=-0.4761;
+a4=-0.00266;
+a5=-0.5941;
+a6=-0.4278;
+
+D={log10(ds)*[a1*log10(dp^2)+a2*[log10(dp)]+a3]}+[a4*log10(dp^2)+a5*[log10(dp)]+a6];
+f=11.01217+0.51244*(log10(dp)-log10(ds));
+N=ceil((D/df)-f+1);
+disp(N,"Order of filter is ");
+
+disp(N*fs1,"Number of multiplications required is: ")
diff --git a/2303/CH10/EX10.4/10_4.sce b/2303/CH10/EX10.4/10_4.sce new file mode 100755 index 000000000..8485ce5ab --- /dev/null +++ b/2303/CH10/EX10.4/10_4.sce @@ -0,0 +1,61 @@ +//Example 10.4
+//3 stage decimation filter design
+clc;
+clear;
+close;
+
+Fs1=3072000; //original signal sampling frequency
+Fs2=48000; //new sampling frequency
+df=64; //decimation factor of filter
+fp1=24000; //pass band edge frequency
+fs=32000; //stop band edge freqeucny
+tw=2000; //transition width
+pbdev=0.00345; //pass band deviation
+sbatt=80; //stop band attenuation in decibel
+fp2=20000;
+
+//filter coefficients required for order of filter
+a1=0.005309;
+a2=0.07114;
+a3=-0.4761;
+a4=-0.00266;
+a5=-0.5941;
+a6=-0.4278;
+
+dp=pbdev/3; //pass band ripple for each stage;
+ds=10^-(sbatt/20); //stop band attenuation for each stage
+f=11.01217+0.51244*(log10(dp)-log10(ds));
+D={log10(ds)*[a1*log10(dp^2)+a2*[log10(dp)]+a3]}+[a4*log10(dp^2)+a5*[log10(dp)]+a6];
+
+//1st stage design
+df1=8; //decimation factor for 1st stage
+F1=Fs1; //input sampling fequency
+F2=F1/df1; //output sampling frequency
+fs1=F2-Fs1/(2*df); //stop band edge frequency
+df1=(fs1-fp1)/Fs1;
+N1=ceil(D/df1-f+1);
+disp(N1,"Order of filter for 1st stage is ");
+n1=N1*F1;
+
+//2nd stage design
+df2=4; //decimation factor for 2nd stage
+F1=F2; //input sampling fequency
+F2=F1/df2; //output sampling frequency
+fs1=F2-Fs1/(2*df); //stop band edge frequency
+df2=(fs1-fp1)/F1;
+N2=ceil(D/df2-f+1);
+disp(N2,"Order of filter for 2nd stage is ");
+n2=N2*F1;
+
+//3rd stage design
+df3=2; //decimation factor for 3rd stage
+F1=F2; //input sampling fequency
+F2=F1/df3; //output sampling frequency
+fs1=F2-Fs1/(2*df); //stop band edge frequency
+df3=(fp1-fp2)/F1;
+N3=ceil(D/df3-f+1);
+disp(N3,"Order of filter for 3rd stage is ");
+n3=N3*F1;
+
+N=n1+n2+n3;
+disp(N,"Number of multiplications required is: ");
diff --git a/2303/CH10/EX10.5/10_5.sce b/2303/CH10/EX10.5/10_5.sce new file mode 100755 index 000000000..4a4cb41da --- /dev/null +++ b/2303/CH10/EX10.5/10_5.sce @@ -0,0 +1,35 @@ +//Example 10.5
+
+clc;
+clear;
+close;
+
+fs1=64000; //original signal sampling frequency
+fs2=2048000; //new sampling frequency
+df=32; //decimation factor of filter
+fp=30000; //pass band edge frequency
+fs=32000; //stop band edge freqeucny
+tw=2000; //transition width
+pbdev=0.01; //pass band deviation in decibel
+sbatt=80; //stop band attenuation in decibe
+
+//Calculating delta-f
+df=tw/fs2;
+//Ca;culating passband and stop band deviations
+dp=10^(pbdev/20)-1;
+ds=10^-(sbatt/20);
+
+//filter coefficients required for order of filter
+a1=0.005309;
+a2=0.07114;
+a3=-0.4761;
+a4=-0.00266;
+a5=-0.5941;
+a6=-0.4278;
+
+D={log10(ds)*[a1*log10(dp^2)+a2*[log10(dp)]+a3]}+[a4*log10(dp^2)+a5*[log10(dp)]+a6];
+f=11.01217+0.51244*(log10(dp)-log10(ds));
+N=ceil(D/df-f+1);
+disp(N,"Order of filter is ");
+
+disp(N*fs2,"Number of multiplications required is: ")
diff --git a/2303/CH10/EX10.6/10_6.sce b/2303/CH10/EX10.6/10_6.sce new file mode 100755 index 000000000..0267665e3 --- /dev/null +++ b/2303/CH10/EX10.6/10_6.sce @@ -0,0 +1,60 @@ +//Example 10.6
+//3 stage interpolation filter design
+clc;
+clear;
+close;
+
+Fs1=48000; //original signal sampling frequency
+Fs2=3072000; //new sampling frequency
+intf=64; //interpolation factor of filter
+fp=20000; //pass band edge frequency
+fs=32000; //stop band edge freqeucny
+tw=2000; //transition width
+pbdev=0.00345; //pass band deviation
+sbatt=80; //stop band attenuation in decibel
+
+//filter coefficients required for order of filter
+a1=0.005309;
+a2=0.07114;
+a3=-0.4761;
+a4=-0.00266;
+a5=-0.5941;
+a6=-0.4278;
+
+dp=pbdev/3; //pass band ripple for each stage;
+ds=10^-(sbatt/20); //stop band attenuation for each stage
+f=11.01217+0.51244*(log10(dp)-log10(ds));
+D={log10(ds)*[a1*log10(dp^2)+a2*[log10(dp)]+a3]}+[a4*log10(dp^2)+a5*[log10(dp)]+a6];
+
+//1st stage design
+intf1=2; //interpolation factor for 1st stage
+F1=Fs1; //input sampling fequency
+F2=F1*intf1; //output sampling frequency
+fs1=F1-Fs2/(2*intf); //stop band edge frequency
+df1=(fs1-fp)/F2;
+N1=ceil(D/df1-f+1);
+disp(N1,"Order of filter for 1st stage is ");
+n1=N1*F2;
+
+//2nd stage design
+intf2=4; //interpolation factor for 2nd stage
+F1=F2; //input sampling fequency
+F2=F1*intf2; //output sampling frequency
+fs2=F1-Fs2/(2*intf); //stop band edge frequency
+df2=(fs2-fs1)/F2;
+N2=ceil(D/df2-f+1);
+disp(N2,"Order of filter for 2nd stage is ");
+n2=N2*F2;
+
+//3rd stage design
+intf3=8; //interpolation factor for 3rd stage
+F1=F2; //input sampling fequency
+F2=F1*intf3; //output sampling frequency
+fs3=F1-Fs2/(2*intf); //stop band edge frequency
+df3=(fs3-fs1)/Fs2;
+N3=ceil(D/df3-f+1);
+disp(N3,"Order of filter for 3rd stage is ");
+n3=N3*F2;
+
+N=n1+n2+n3;
+disp(N,"Number of multiplications required is: ");
diff --git a/2303/CH3/EX3.1/EX_3_1.sce b/2303/CH3/EX3.1/EX_3_1.sce new file mode 100755 index 000000000..a81e92df4 --- /dev/null +++ b/2303/CH3/EX3.1/EX_3_1.sce @@ -0,0 +1,43 @@ +//Ex.3.1
+clc;
+clear;
+close;
+x1=[1 2 3 4]; //assume
+x2=[1 2 1 2]; //assume
+a=1;
+b=1;
+y=[2 2 2 2]; //y(n)=2 for all x
+
+//Test for homogeneity
+k=2;
+hom=0;
+for n=1: length (x1)
+ if (k*y(n)==k*x1(n))
+ hom=hom+1;
+ end
+end
+
+//Test for additivity
+for n =1: length (x1)
+ x3(n)=a*x1(n)+b*x2(n)
+end
+for n =1: length (x1)
+ y1(n)=2;
+ y2(n)=2;
+ y3(n)=2;
+end
+for n =1: length (y1)
+ z(n)=a*y1(n)+b*y2(n);
+end
+count =0;
+for n =1: length (y1)
+ if(y3(n)==z(n))
+ count = count +1;
+ end
+end
+if( count == length (y3) & (hom==length(y)))
+ disp ( 'It satisfies the homogeneity and additivity principle' );
+ disp ( 'THE GIVEN SYSTEM IS LINEAR ' );
+else
+ disp ( 'It does not satisfy the homogeneity and additivity principle' );
+ disp ( 'THE GIVEN SYSTEM IS NON LINEAR ' );
diff --git a/2303/CH3/EX3.11/EX_3_11.sce b/2303/CH3/EX3.11/EX_3_11.sce new file mode 100755 index 000000000..40072643a --- /dev/null +++ b/2303/CH3/EX3.11/EX_3_11.sce @@ -0,0 +1,18 @@ +//Ex 3.11
+//MAXIMA SCILAB TOOLBOX REQUIRED FOR THIS PROGRAM
+
+clear;
+clc ;
+close ;
+syms n;
+a=0.5; //assume constant value
+x =(a)^n;
+X1= symsum (x,n ,0, %inf );
+
+a=2; //assume constant value
+X2= symsum (x,n ,0, %inf );
+if (X1<=%inf)
+ disp('Hence Summation < infinity. Given System is Stable for |a| < 1');
+elseif (X2<=%inf)
+ disp('Hence Summation < infinity. Given System is Stable for |a| > 1');
+end
diff --git a/2303/CH3/EX3.2/EX_3_2.sce b/2303/CH3/EX3.2/EX_3_2.sce new file mode 100755 index 000000000..962c7699e --- /dev/null +++ b/2303/CH3/EX3.2/EX_3_2.sce @@ -0,0 +1,44 @@ +//Ex.3.2
+clc;
+clear;
+close;
+x1=[1 2 3 4]; //assume
+x2=[1 2 1 2]; //assume
+a=1;
+b=1;
+c=[5 5 5 5]; //assuming constant value
+y=x1+c; //y(n)=x(n)+c
+
+//Test for homogeneity
+k=2;
+hom=0;
+for n=1: length (x1)
+ if (k*y(n)==k*x1(n)+c(n))
+ hom=hom+1;
+ end
+end
+
+//Test for additivity
+for n =1: length (x1)
+ x3(n)=a*x1(n)+b*x2(n)
+end
+for n =1: length (x1)
+ y1(n)=x1(n)+c(n);
+ y2(n)=x2(n)+c(n);
+ y3(n)=x3(n)+c(n);
+end
+for n =1: length (y1)
+ z(n)=a*y1(n)+b*y2(n);
+end
+count =0;
+for n =1: length (y1)
+ if(y3(n)==z(n))
+ count = count +1;
+ end
+end
+if( count == length (y3) & (hom==length(y)))
+ disp ( 'It satisfies the homogeneity and additivity principle' );
+ disp ( 'THE GIVEN SYSTEM IS LINEAR ' );
+else
+ disp ( 'It does not satisfy the homogeneity and additivity principle' );
+ disp ( 'THE GIVEN SYSTEM IS NON LINEAR ' );
diff --git a/2303/CH3/EX3.3/EX_3_3.sce b/2303/CH3/EX3.3/EX_3_3.sce new file mode 100755 index 000000000..74f87c665 --- /dev/null +++ b/2303/CH3/EX3.3/EX_3_3.sce @@ -0,0 +1,43 @@ +//Ex.3.3
+clc;
+clear;
+close;
+x1=[1 -2 3 -4]; //assume
+x2=[-1 2 -1 2]; //assume
+a=1;
+b=1;
+y=abs(x1); //y(n)=x(n)+c
+
+//Test for homogeneity
+k=2;
+hom=0;
+for n=1: length (x1)
+ if (k*y(n)==abs(k*x1(n)))
+ hom=hom+1;
+ end
+end
+
+//Test for additivity
+for n =1: length (x1)
+ x3(n)=a*x1(n)+b*x2(n)
+end
+for n =1: length (x1)
+ y1(n)=abs(x1(n));
+ y2(n)=abs(x2(n));
+ y3(n)=abs(x3(n));
+end
+for n =1: length (y1)
+ z(n)=a*y1(n)+b*y2(n);
+end
+count =0;
+for n =1: length (y1)
+ if(y3(n)==z(n))
+ count = count +1;
+ end
+end
+if( count == length (y3) & (hom==length(y)))
+ disp ( 'It satisfies the homogeneity and additivity principle' );
+ disp ( 'THE GIVEN SYSTEM IS LINEAR ' );
+else
+ disp ( 'It does not satisfy the homogeneity and additivity principle' );
+ disp ( 'THE GIVEN SYSTEM IS NON LINEAR ' );
diff --git a/2303/CH3/EX3.4/EX_3_4.sce b/2303/CH3/EX3.4/EX_3_4.sce new file mode 100755 index 000000000..565cdf091 --- /dev/null +++ b/2303/CH3/EX3.4/EX_3_4.sce @@ -0,0 +1,61 @@ +//Ex.3.4
+
+clc ;
+clear;
+close;
+
+//Test for shift-variance
+k =2;
+N =10;
+for n =1: N
+x(n)=n;
+y(n)=x(1);
+end
+inputshift =x(N-k);
+outputshift =y(N-k);
+if( inputshift == outputshift )
+ disp ( 'THE GIVEN SYSTEM IS SHIFT INVARIANT ' )
+else
+ disp ( 'THE GIVEN SYSTEM IS SHIFT VARIANT ' );
+end
+
+//Test for linearity
+x1=[1 2 3 4]; //assume
+x2=[1 2 1 2]; //assume
+a=1;
+b=1;
+y=[1 1 1 1]; //y(n)=x(1) for all x
+
+ //Test for homogeneity
+k=2;
+hom=0;
+for n=1: length (x1)
+ if (k*y(n)==k*x1(n))
+ hom=hom+1;
+ end
+end
+
+ //Test for additivity
+for n =1: length (x1)
+ x3(n)=a*x1(n)+b*x2(n)
+end
+for n =1: length (x1)
+ y1(n)=x(1);
+ y2(n)=x(1);
+ y3(n)=x(1);
+end
+for n =1: length (y1)
+ z(n)=a*y1(n)+b*y2(n);
+end
+count =0;
+for n =1: length (y1)
+ if(y3(n)==z(n))
+ count = count +1;
+ end
+end
+if( count == length (y3) & (hom==length(y)))
+ disp ( 'It satisfies the homogeneity and additivity principle' );
+ disp ( 'THE GIVEN SYSTEM IS LINEAR ' );
+else
+ disp ( 'It does not satisfy the homogeneity and additivity principle' );
+ disp ( 'THE GIVEN SYSTEM IS NON LINEAR ' );
diff --git a/2303/CH3/EX3.5/EX_3_5.sce b/2303/CH3/EX3.5/EX_3_5.sce new file mode 100755 index 000000000..693969077 --- /dev/null +++ b/2303/CH3/EX3.5/EX_3_5.sce @@ -0,0 +1,61 @@ +//Ex.3.5
+
+clc ;
+clear;
+close;
+
+//Test for shift-variance
+k =2;
+N =10;
+for n =1: N
+x(n)=n;
+y(n)=x(n)^2;
+end
+inputshift =[x(N-k)]^2;
+outputshift =y(N-k);
+if( inputshift == outputshift )
+ disp ( 'THE GIVEN SYSTEM IS SHIFT INVARIANT ' )
+else
+ disp ( 'THE GIVEN SYSTEM IS SHIFT VARIANT ' );
+end
+
+//Test for linearity
+x1=[1 2 3 4]; //assume
+x2=[1 2 1 2]; //assume
+a=1;
+b=1;
+y=[1 4 9 16]; //y(n)=x(n)^2 for all x
+
+ //Test for homogeneity
+k=2;
+hom=0;
+for n=1: length (x1)
+ if (k*y(n)==[k*x1(n)]^2)
+ hom=hom+1;
+ end
+end
+
+ //Test for additivity
+for n =1: length (x1)
+ x3(n)=a*x1(n)+b*x2(n)
+end
+for n =1: length (x1)
+ y1(n)=x(n)^2;
+ y2(n)=x(n)^2;
+ y3(n)=x(n)^2;
+end
+for n =1: length (y1)
+ z(n)=a*y1(n)+b*y2(n);
+end
+count =0;
+for n =1: length (y1)
+ if(y3(n)==z(n))
+ count = count +1;
+ end
+end
+if( count == length (y3) & (hom==length(y)))
+ disp ( 'It satisfies the homogeneity and additivity principle' );
+ disp ( 'THE GIVEN SYSTEM IS LINEAR ' );
+else
+ disp ( 'It does not satisfy the homogeneity and additivity principle' );
+ disp ( 'THE GIVEN SYSTEM IS NON LINEAR ' );
diff --git a/2303/CH3/EX3.6/EX_3_6.sce b/2303/CH3/EX3.6/EX_3_6.sce new file mode 100755 index 000000000..c449bc5b5 --- /dev/null +++ b/2303/CH3/EX3.6/EX_3_6.sce @@ -0,0 +1,62 @@ +//Ex.3.6
+
+clc ;
+clear;
+close;
+//since in Scilab,the index starts from 1, we write the above system as y(n+1)=x(n)
+//Test for shift-variance
+k =2;
+N =10;
+for n =1: N
+x(n)=n;
+y(n+1)=x(n);
+end
+inputshift =x(N-k);
+outputshift =y(N+1-k);
+if( inputshift == outputshift )
+ disp ( 'THE GIVEN SYSTEM IS SHIFT INVARIANT ' )
+else
+ disp ( 'THE GIVEN SYSTEM IS SHIFT VARIANT ' );
+end
+
+//Test for linearity
+x1=[1 2 3 4]; //assume
+x2=[1 2 1 2]; //assume
+a=1;
+b=1;
+y=[0 1 2 3]; //y(n)=x1(n-1)
+
+ //Test for homogeneity
+k=2;
+hom=0;
+for n=1: length (x1)-1
+ if (k*y(n+1)==k*x1(n))
+ hom=hom+1;
+end
+end
+
+ //Test for additivity
+for n =1: length (x1)
+ x3(n)=a*x1(n)+b*x2(n)
+end
+for n =1: length (x1)-1
+ y1(n+1)=x1(n);
+ y2(n+1)=x2(n);
+ y3(n+1)=x3(n);
+end
+for n =1: length (y1)-1
+ z(n+1)=a*y1(n+1)+b*y2(n+1);
+end
+count =0;
+for n =1: length (y1)-1
+ if(y3(n+1)==z(n+1))
+ count = count +1;
+ end
+end
+if(( count == length (y3)-1) & (hom==length(y)-1))
+ disp ( 'It satisfies the homogeneity and additivity principle' );
+ disp ( 'THE GIVEN SYSTEM IS LINEAR ' );
+else
+ disp ( 'It does not satisfy the homogeneity and additivity principle' );
+ disp ( 'THE GIVEN SYSTEM IS NON LINEAR ' );
+end
diff --git a/2303/CH4/EX4.1/4_1.sce b/2303/CH4/EX4.1/4_1.sce new file mode 100755 index 000000000..d6e230d20 --- /dev/null +++ b/2303/CH4/EX4.1/4_1.sce @@ -0,0 +1,12 @@ +//Example 4.1
+//MAXIMA SCILAB TOOLBOX REQUIRED FOR THIS PROGRAM
+
+clear;
+clc ;
+close ;
+syms n z;
+f = 1;
+F= symsum (f*(z^(-n)),n ,0, %inf );
+//Display the result in command window
+disp (F,"Z-transform of f(n)=1 for all n>=0 with is:");
+disp('ROC is the Region |Z|>1 ');
diff --git a/2303/CH4/EX4.2/4_2.sce b/2303/CH4/EX4.2/4_2.sce new file mode 100755 index 000000000..e409d2a06 --- /dev/null +++ b/2303/CH4/EX4.2/4_2.sce @@ -0,0 +1,17 @@ +//Example 4.2
+//MAXIMA SCILAB TOOLBOX REQUIRED FOR THIS PROGRAM
+
+clear;
+clc ;
+close ;
+syms n z a;
+f =e^(-n*a*T);
+F= symsum (f*(z^(-n)),n ,0, %inf );
+
+//Display the result in command window
+disp (F,"Z-transform of e^(-a*n*T)u(n) is:");
+disp('ROC is the Region mod(z) > mod(e^(-a*T))');
+disp('Case 1: a is real ');
+disp('ROC is the Region mod(z) > e^(-a*T)');
+disp('Case 2: a is imaginary ');
+disp('ROC is the Region mod(z) > 1');
diff --git a/2303/CH4/EX4.3/4_3.sce b/2303/CH4/EX4.3/4_3.sce new file mode 100755 index 000000000..a92e98916 --- /dev/null +++ b/2303/CH4/EX4.3/4_3.sce @@ -0,0 +1,17 @@ +//Example 4.3
+//MAXIMA SCILAB TOOLBOX REQUIRED FOR THIS PROGRAM
+
+clear;
+clc ;
+close ;
+
+j=sqrt(-1);
+syms w n z T j;
+f1=exp(j*w*T*n);
+F1=symsum(f1*(z^-n),n,0,%inf);
+f2=exp(-j*w*T*n);
+F2=symsum(f2*(z^-n),n,0,%inf);
+F=(F1-F2)/(2*j);
+//Display the result in command window
+disp (F,"Z-transform of sin(n*w*T) u(n) is:");
+disp('ROC is the Region mod(z) > 1);
diff --git a/2303/CH4/EX4.4/4_4.sce b/2303/CH4/EX4.4/4_4.sce new file mode 100755 index 000000000..a221be391 --- /dev/null +++ b/2303/CH4/EX4.4/4_4.sce @@ -0,0 +1,19 @@ +//Example 4.4
+//MAXIMA SCILAB TOOLBOX REQUIRED FOR THIS PROGRAM
+
+clear;
+clc ;
+close ;
+syms n z a;
+
+f1=a^n;
+F1= symsum (f1*(z^(-n)),n ,0, %inf );
+
+f2=-a^n;
+F2= symsum (f2*(z^(-n)),n ,-%inf, 1 );
+//Display the result in command window
+disp (F1,"Z-transform of a^n for n>=0 is:");
+disp('ROC is the Region mod(z) > a');
+
+disp (F2,"Z-transform of -a^n for n>=0 is:");
+disp('ROC is the Region mod(z) < a');
diff --git a/2303/CH4/EX4.5/4_5.sce b/2303/CH4/EX4.5/4_5.sce new file mode 100755 index 000000000..5740448fb --- /dev/null +++ b/2303/CH4/EX4.5/4_5.sce @@ -0,0 +1,17 @@ +//Example 4.5
+//MAXIMA SCILAB TOOLBOX REQUIRED FOR THIS PROGRAM
+
+clear;
+clc ;
+close ;
+syms b n z;
+
+f1=b^n;
+F1= symsum (f1*(z^(-n)),n ,0, %inf );
+
+f2=b^-n;
+F2= symsum (f2*(z^(-n)),n ,-%inf, -1 );
+//Display the result in command window
+F=F1+F2;
+disp (F,"Z-transform of b^|n| is:");
+disp('ROC is the Region b < mod(z) <1/b')
diff --git a/2303/CH4/EX4.6/4_6.sce b/2303/CH4/EX4.6/4_6.sce new file mode 100755 index 000000000..9156ad586 --- /dev/null +++ b/2303/CH4/EX4.6/4_6.sce @@ -0,0 +1,17 @@ +//Example 4.6
+//MAXIMA SCILAB TOOLBOX REQUIRED FOR THIS PROGRAM
+
+clear;
+clc ;
+close ;
+syms n z;
+
+f1=1;
+F1= symsum (f1*(z^(-n)),n ,-%inf, -1 );
+
+f2=(0.5)^n;
+F2= symsum (f2*(z^(-n)),n ,0,%inf );
+//Display the result in command window
+F=F1+F2;
+disp (F,"Z-transform of f(n) is:");
+disp('ROC is the Region 0.5 < mod(z) <1 ')
diff --git a/2303/CH4/EX4.7/4_7.sce b/2303/CH4/EX4.7/4_7.sce new file mode 100755 index 000000000..8b6fb6607 --- /dev/null +++ b/2303/CH4/EX4.7/4_7.sce @@ -0,0 +1,17 @@ +//Example 4.7
+//MAXIMA SCILAB TOOLBOX REQUIRED FOR THIS PROGRAM
+
+clear;
+clc ;
+close ;
+syms n z;
+
+f1=(1/2)^n;
+F1= symsum (f1*(z^(-n)),n ,0, %inf );
+
+f2=(1/3)^n;
+F2= symsum (f2*(z^(-n)),n ,0,%inf );
+//Display the result in command window
+F=F1+F2; //linearity property
+disp (F,"Z-transform of f(n) is:");
+disp('ROC is the Region mod(z) > (1/2) ')
diff --git a/2303/CH4/EX4.8/4_8.sce b/2303/CH4/EX4.8/4_8.sce new file mode 100755 index 000000000..0b4a15e16 --- /dev/null +++ b/2303/CH4/EX4.8/4_8.sce @@ -0,0 +1,17 @@ +//Example 4.8
+//MAXIMA SCILAB TOOLBOX REQUIRED FOR THIS PROGRAM
+
+clear;
+clc ;
+close ;
+syms n z a;
+
+f1=a^n;
+F1= symsum (f1*(z^(-n)),n ,0, %inf );
+
+f2=a^n;
+F2= symsum (f2*(z^(-n)),n ,1,%inf );
+//Display the result in command window
+F=F1-F2; //linearity property
+disp (F,"Z-transform of f(n) is:");
+disp('ROC is the entire Z-domain ')
diff --git a/2303/CH4/EX4.9/4_9.sce b/2303/CH4/EX4.9/4_9.sce new file mode 100755 index 000000000..e4fae612e --- /dev/null +++ b/2303/CH4/EX4.9/4_9.sce @@ -0,0 +1,17 @@ +//Example 4.9
+//MAXIMA SCILAB TOOLBOX REQUIRED FOR THIS PROGRAM
+
+clear;
+clc ;
+close ;
+
+syms a n Z;
+x1=a^n; //for all n>=0
+X1=Z/(Z-a); //ROC is mod(Z)>a
+x2=x1(n-2);
+
+//Time shifting property
+X2=[Z^(-2)]*X1;
+
+//Display the result in command window
+disp (X2,"Z-transform of x(n-2) is:");
diff --git a/2303/CH5/EX5.1/5_1.sce b/2303/CH5/EX5.1/5_1.sce new file mode 100755 index 000000000..5b86a8373 --- /dev/null +++ b/2303/CH5/EX5.1/5_1.sce @@ -0,0 +1,17 @@ +//Example 5.1
+
+
+clc;
+clear;
+close;
+x=[0 1 2 3];
+//compute DFT by definition
+w=-%i;
+X=[0 0 0 0]
+for i=1:4
+ for j=1:4
+ X(i)=X(i)+x(j)*w^((i-1)*(j-1));
+ end
+end
+//Displaying DFT
+disp(X,"X[k]=");
diff --git a/2303/CH5/EX5.10/5_10.sce b/2303/CH5/EX5.10/5_10.sce new file mode 100755 index 000000000..84ae895b1 --- /dev/null +++ b/2303/CH5/EX5.10/5_10.sce @@ -0,0 +1,11 @@ +//Example 5.10
+
+clc;
+clear;
+close;
+
+x=[1 2 3 4 1 2 3 4]
+y=fft(x,-1);
+
+//displaying 2nd DFT coefficient
+disp(y(3),"X(2)=");
diff --git a/2303/CH5/EX5.2/5_2.sce b/2303/CH5/EX5.2/5_2.sce new file mode 100755 index 000000000..ad580e0dc --- /dev/null +++ b/2303/CH5/EX5.2/5_2.sce @@ -0,0 +1,9 @@ +//Example 5.2
+clear;
+clc ;
+close ;
+x = [1,2,3,4,5,2,3,1];
+//DFT Computation
+X = fft (x , -1);
+//Display sequence X[k] in command window
+disp(X,"X[k]=");
diff --git a/2303/CH5/EX5.3/5_3.sce b/2303/CH5/EX5.3/5_3.sce new file mode 100755 index 000000000..d9f09ca52 --- /dev/null +++ b/2303/CH5/EX5.3/5_3.sce @@ -0,0 +1,15 @@ +//Example 5.3
+clear;
+clc ;
+close ;
+x = [1,2,3,4,5,2,3,1];
+//DFT Computation
+X = fft (x , -1);
+X2=X;
+
+//Display sequence X[k] in command window
+disp(X,"X[k]=");
+
+//Time reversal property
+X2=[X2(1), X2(length(X2):-1:2)];
+disp(X2,"X[-k]=",'By Time reversal property DFT of x[-n] is:');
diff --git a/2303/CH5/EX5.4/5_4.sce b/2303/CH5/EX5.4/5_4.sce new file mode 100755 index 000000000..561f69fc0 --- /dev/null +++ b/2303/CH5/EX5.4/5_4.sce @@ -0,0 +1,28 @@ +//Example 5.4
+clear;
+clc ;
+close ;
+x = [1,2,3,4,5,2,3,1];
+disp(x,"x[n]=");
+//DFT Computation
+X = fft (x , -1);
+//Display sequence X[k] in command window
+disp(X,"X[k]=");
+
+//Finding time shifted input sequence x[n-2]
+y=x;
+for i=1:2
+ a=y(1);
+ for j=1:length(y)-1
+ y(j)=y(j+1);
+ end
+ y(length(y))=a;
+end
+disp(y,"x2[n]=x[n-2]=");
+//using Time-shifting property
+X2=[zeros(1:8)];
+w=-%i;
+for j=1:8
+ X2(j)=[(w)^(j-1)]*X(j);
+end
+disp(X2,"Using time-shifting property,DFT of x[n-2]=X2[k]=");
diff --git a/2303/CH5/EX5.5/5_5.sce b/2303/CH5/EX5.5/5_5.sce new file mode 100755 index 000000000..97f2b020c --- /dev/null +++ b/2303/CH5/EX5.5/5_5.sce @@ -0,0 +1,44 @@ +//Example 5.5
+
+clear;
+clc ;
+close ;
+x = [1,2,2,1,1,2,1,1];
+a=[x(1:4)];
+b=[x(5:8)];
+w=(sqrt(2)-%i*sqrt(2))/2;
+
+//1st iteration=====8 point DFT
+for i=1:4
+ h(i)=a(i)+b(i);
+ g(i)=[a(i)-b(i)]*(w^(i-1))
+end
+
+//2nd iteration=====4 point DFT
+for i=1:2
+ h1(i)=h(i)+h(i+2);
+ g1(i)=[h(i)-h(i+2)]*(w^(2*(i-1)));
+ h2(i)=g(i)+g(i+2);
+ g2(i)=[g(i)-g(i+2)]*(w^(2*(i-1)));
+end
+
+//3rd iteration=====2 point DFT
+y=[zeros(1:8)];
+y(1)=h1(1)+h1(2);
+y(2)=[h1(1)-h1(2)]*(w^0);
+y(3)=g1(1)+g1(2);
+y(4)=[g1(1)-g1(2)]*(w^0);
+y(5)=h2(1)+h2(2);
+y(6)=[h2(1)-h2(2)]*(w^0);
+y(7)=g2(1)+g2(2);
+y(8)=[g2(1)-g2(2)]*(w^0);
+
+//Bit reversed output
+X=y;
+X(2)=y(5);
+X(5)=y(2);
+X(4)=y(7);
+X(7)=y(4);
+//Display sequence X[k] in command window
+disp(X,"X[k]=");
+
diff --git a/2303/CH5/EX5.6/5_6.sce b/2303/CH5/EX5.6/5_6.sce new file mode 100755 index 000000000..87d9d58c8 --- /dev/null +++ b/2303/CH5/EX5.6/5_6.sce @@ -0,0 +1,41 @@ +//Example 5.6
+clear;
+clc ;
+close ;
+x = [1,2,2,1,1,2,1,1];
+w=(sqrt(2)-%i*sqrt(2))/2;
+
+//split input into four 2-point sequences
+a=[x(1) x(5)]
+b=[x(3) x(7)]
+c=[x(2) x(6)]
+d=[x(4) x(8)]
+
+//1st iteration======2 point DFT
+y1(1)=a(1)+a(2);
+y1(2)=a(1)-a(2);
+y1(3)=[b(1)+b(2)]*(w^0);
+y1(4)=[b(1)-b(2)]*(w^2);
+y1(5)=c(1)+c(2);
+y1(6)=c(1)-c(2);
+y1(7)=[d(1)+d(2)]*(w^0);
+y1(8)=[d(1)-d(2)]*(w^2);
+
+//2nd iteration=======4 point DFT
+for i=1:2
+ h2(i)=y1(i)+y1(i+2);
+ g2(i)=y1(i)-y1(i+2);
+ h3(i)=[y1(4+i)+y1(6+i)]*(w^(i-1));
+ g3(i)=[y1(4+i)-y1(6+i)]*(w^(i+1));
+end
+
+//3rd iteration=======8 point DFT
+for i=1:2
+ X(i)=h2(i)+h3(i);
+ X(i+2)=g2(i)+g3(i);
+ X(i+4)=h2(i)-h3(i);
+ X(i+6)=g2(i)-g3(i);
+end
+
+//Display sequence X[k] in command window
+disp(X,"X[k]=");
diff --git a/2303/CH5/EX5.7/5_7.sce b/2303/CH5/EX5.7/5_7.sce new file mode 100755 index 000000000..a292ff324 --- /dev/null +++ b/2303/CH5/EX5.7/5_7.sce @@ -0,0 +1,42 @@ +//Example 5.7
+// overlap and add method
+clc;
+clear;
+close;
+x=[1,2,3,4,5,1,2,3,4,5,1,2,3,4,5];
+h=[3,2,1,1];
+L=5;
+M=length(h);
+N=1:L+M-1;
+n=length(N);
+
+h1=[h,zeros(1:4)];
+
+x1=[x(1:L),zeros(1:3)];
+x2=[x(6:2*L),zeros(1:3)];
+x3=[x(11:3*L),zeros(1:3)];
+
+//Convolution
+y1=convol(x1,h1);
+y2=convol(x2,h1);
+y3=convol(x3,h1);
+
+//Display sequence y[n] in command window
+for i=1:5
+ y(i)=y1(i)
+end
+for i=6:8
+ y(i)=y1(i)+y2(i-L)
+end
+for i=9:10
+ y(i)=y2(i-L)
+end
+for i=11:13
+ y(i)=y2(i-L)+y3(i-2*L)
+end
+for i=14:18
+ y(i)=y3(i-2*L)
+end
+
+disp( "The convolution of x[n]=[1,2,3,4,5,1,2,3,4,5,1,2,3,4,5] and h[n]=[3,2,1,1] is ");
+disp(y,"y[n]=")
diff --git a/2303/CH5/EX5.8/5_8.sce b/2303/CH5/EX5.8/5_8.sce new file mode 100755 index 000000000..6ba5c6e04 --- /dev/null +++ b/2303/CH5/EX5.8/5_8.sce @@ -0,0 +1,45 @@ +//Example 5.8
+//overlap and save method
+clc;
+clear;
+close;
+x=[1,2,3,4,5,1,2,3,4,5,1,2,3,4,5];
+h=[3,2,1,1];
+L=5;
+M=length(h);
+N=1:L+M-1;
+n=length(N);
+
+h1=[h,zeros(1:4)];
+x1=[zeros(1:3),x(1:L)];
+x2=[x1(6:n),x(6:2*L)];
+x3=[x2(6:n),x(11:3*L)];
+
+//Circular Convolution by linear convolution and padding zeros method
+y1=conv(x1,h);
+y2=conv(x2,h);
+y3=conv(x3,h);
+
+y1(15:16)=0;
+c1=y1(1:8)+y1(9:16);
+y2(15:16)=0;
+c2=y2(1:8)+y2(9:16);
+y3(15:16)=0;
+c3=y3(1:8)+y3(9:16);
+
+//Display sequence y[n] in command window
+for i=1:L
+ y(i)=c1(i+3)
+end
+for i=6:2*L
+ y(i)=c2(i-2)
+end
+for i=11:3*L
+ y(i)=c3(i-7)
+end
+for i=16:18
+ y(i)=c1(i-15)
+end
+
+disp( "The convolution of x[n]=[1,2,3,4,5,1,2,3,4,5,1,2,3,4,5] and h[n]=[3,2,1,1] is ");
+disp(y,"y[n]=")
diff --git a/2303/CH5/EX5.9/5_9.sce b/2303/CH5/EX5.9/5_9.sce new file mode 100755 index 000000000..792417b89 --- /dev/null +++ b/2303/CH5/EX5.9/5_9.sce @@ -0,0 +1,27 @@ +//Example 5.9
+clc;
+clear;
+close;
+
+//let
+x=[1 2 3 4];
+h=[5 6 7];
+M=length(x);
+N=length(h);
+
+//Result of linear convolution of original sequences
+y=conv(x,h);
+disp(y,"Result of linear convolution of original sequences is");
+
+L=M+N-1;
+//we append zeros such that total sequence will have length 6.
+x=[zeros(1:2),x];
+h=[h,zeros(1:2)];
+
+//Result of circular convolution of sequence appended with 2 zeros at start
+y=conv(x,h);
+y(11:12)=0;
+y=y(1:6)+y(7:12)
+disp(y,"Result of circular convolution of sequences appended with 2 zeros at start is");
+
+disp("We see that if we circularly rotate the result of circular convolution by 2 samples, we get the linear convolution result");
|