From b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b Mon Sep 17 00:00:00 2001 From: priyanka Date: Wed, 24 Jun 2015 15:03:17 +0530 Subject: initial commit / add all books --- 830/CH12/EX12.1.1/spectrum_of_signal.sce | 27 +++++++++ 830/CH12/EX12.1.2/spectrum_using_DFT.sce | 81 +++++++++++++++++++++++++ 830/CH12/EX12.5.1/Additive_Noise_Parameters.sce | 26 ++++++++ 3 files changed, 134 insertions(+) create mode 100755 830/CH12/EX12.1.1/spectrum_of_signal.sce create mode 100755 830/CH12/EX12.1.2/spectrum_using_DFT.sce create mode 100755 830/CH12/EX12.5.1/Additive_Noise_Parameters.sce (limited to '830/CH12') diff --git a/830/CH12/EX12.1.1/spectrum_of_signal.sce b/830/CH12/EX12.1.1/spectrum_of_signal.sce new file mode 100755 index 000000000..32b8c187f --- /dev/null +++ b/830/CH12/EX12.1.1/spectrum_of_signal.sce @@ -0,0 +1,27 @@ +//Graphical// +//Example 12.1.1 +//Determination of spectrum of a signal +//With maximum normalized frequency f = 0.1 +//using Rectangular window and Blackmann window +clear; +close; +clc; +N = 61; +cfreq = [0.1 0]; +[wft,wfm,fr]=wfir('lp',N,cfreq,'re',0); +wft; // Time domain filter coefficients +wfm; // Frequency domain filter values +fr; // Frequency sample points +WFM_dB = 20*log10(wfm);//Frequency response in dB +for n = 1:N + h_balckmann(n)=0.42-0.5*cos(2*%pi*n/(N-1))+0.08*cos(4*%pi*n/(N-1)); +end +wft_blmn = wft'.*h_balckmann; +wfm_blmn = frmag(wft_blmn,length(fr)); +WFM_blmn_dB =20*log10(wfm_blmn); +subplot(2,1,1) +plot2d(fr,WFM_dB) +xtitle('Frequency Response of Rectangular window Filtered output M = 61','Frequency in cycles per samples f','Energy density in dB') +subplot(2,1,2) +plot2d(fr,WFM_blmn_dB) +xtitle('Frequency Response of Blackmann window Filtered output M = 61','Frequency in cycles per samples f','Energy density in dB') diff --git a/830/CH12/EX12.1.2/spectrum_using_DFT.sce b/830/CH12/EX12.1.2/spectrum_using_DFT.sce new file mode 100755 index 000000000..506617bcb --- /dev/null +++ b/830/CH12/EX12.1.2/spectrum_using_DFT.sce @@ -0,0 +1,81 @@ +//Graphical// +//Example 12.1.2 +//Evaluating power spectrum of a discrete sequence +//Using N-point DFT +clear; +clc; +close; +N =16; //Number of samples in given sequence +n =0:N-1; +delta_f = [0.06,0.01];//frequency separation +x1 = sin(2*%pi*0.315*n)+cos(2*%pi*(0.315+delta_f(1))*n); +x2 = sin(2*%pi*0.315*n)+cos(2*%pi*(0.315+delta_f(2))*n); +L = [8,16,32,128]; +k1 = 0:L(1)-1; +k2 = 0:L(2)-1; +k3 = 0:L(3)-1; +k4 = 0:L(4)-1; +fk1 = k1./L(1); +fk2 = k2./L(2); +fk3 = k3./L(3); +fk4 = k4./L(4); +for i =1:length(fk1) + Pxx1_fk1(i) = 0; + Pxx2_fk1(i) = 0; + for m = 1:N + Pxx1_fk1(i)=Pxx1_fk1(i)+x1(m)*exp(-sqrt(-1)*2*%pi*(m-1)*fk1(i)); + Pxx2_fk1(i)=Pxx1_fk1(i)+x1(m)*exp(-sqrt(-1)*2*%pi*(m-1)*fk1(i)); + end + Pxx1_fk1(i) = (Pxx1_fk1(i)^2)/N; + Pxx2_fk1(i) = (Pxx2_fk1(i)^2)/N; +end +for i =1:length(fk2) + Pxx1_fk2(i) = 0; + Pxx2_fk2(i) = 0; + for m = 1:N + Pxx1_fk2(i)=Pxx1_fk2(i)+x1(m)*exp(-sqrt(-1)*2*%pi*(m-1)*fk2(i)); + Pxx2_fk2(i)=Pxx1_fk2(i)+x1(m)*exp(-sqrt(-1)*2*%pi*(m-1)*fk2(i)); + end + Pxx1_fk2(i) = (Pxx1_fk2(i)^2)/N; + Pxx2_fk2(i) = (Pxx1_fk2(i)^2)/N; +end +for i =1:length(fk3) + Pxx1_fk3(i) = 0; + Pxx2_fk3(i) = 0; + for m = 1:N + Pxx1_fk3(i) =Pxx1_fk3(i)+x1(m)*exp(-sqrt(-1)*2*%pi*(m-1)*fk3(i)); + Pxx2_fk3(i) =Pxx1_fk3(i)+x1(m)*exp(-sqrt(-1)*2*%pi*(m-1)*fk3(i)); + end + Pxx1_fk3(i) = (Pxx1_fk3(i)^2)/N; + Pxx2_fk3(i) = (Pxx1_fk3(i)^2)/N; +end +for i =1:length(fk4) + Pxx1_fk4(i) = 0; + Pxx2_fk4(i) = 0; + for m = 1:N + Pxx1_fk4(i) =Pxx1_fk4(i)+x1(m)*exp(-sqrt(-1)*2*%pi*(m-1)*fk4(i)); + Pxx2_fk4(i) =Pxx1_fk4(i)+x1(m)*exp(-sqrt(-1)*2*%pi*(m-1)*fk4(i)); + end + Pxx1_fk4(i) = (Pxx1_fk4(i)^2)/N; + Pxx2_fk4(i) = (Pxx1_fk4(i)^2)/N; +end +figure +title('for frequency separation = 0.06') +subplot(2,2,1) +plot2d3('gnn',k1,abs(Pxx1_fk1)) +subplot(2,2,2) +plot2d3('gnn',k2,abs(Pxx1_fk2)) +subplot(2,2,3) +plot2d3('gnn',k3,abs(Pxx1_fk3)) +subplot(2,2,4) +plot2d3('gnn',k4,abs(Pxx1_fk4)) +figure +title('for frequency separation = 0.01') +subplot(2,2,1) +plot2d3('gnn',k1,abs(Pxx2_fk1)) +subplot(2,2,2) +plot2d3('gnn',k2,abs(Pxx2_fk2)) +subplot(2,2,3) +plot2d3('gnn',k3,abs(Pxx2_fk3)) +subplot(2,2,4) +plot2d3('gnn',k4,abs(Pxx2_fk4)) diff --git a/830/CH12/EX12.5.1/Additive_Noise_Parameters.sce b/830/CH12/EX12.5.1/Additive_Noise_Parameters.sce new file mode 100755 index 000000000..b59e316b7 --- /dev/null +++ b/830/CH12/EX12.5.1/Additive_Noise_Parameters.sce @@ -0,0 +1,26 @@ +//Graphical// +//Example 12.5.1 +//Determination of power, frequency and varaince of +//Additive noise +clear; +clc; +close; +ryy = [0,1,3,1,0];//Autocorrelation of signal +cen_ter_value = ceil(length(ryy)/2);//center value of autocorrelation +//Method1 +//TO find out the variance of the additive Noise +C = ryy(ceil(length(ryy)/2):$); +corr_matrix = toeplitz(C);//correlation matrix +evals =spec(corr_matrix);//Eigen Values computation +sigma_w = min(evals);//Minimum of eigen value = varinace of noise +//Method2 +//TO find out the variance of the additive Noise +P = [1,-sqrt(2),1];//Ploynomial in decreasing order +Z = roots(P);//roots of the polynomial +P1 = ryy(cen_ter_value+1)/real(Z(1));//power of the sinusoid +A = sqrt(2*P1);//amplitude of the sinusoid +sigma_w1 = ryy(cen_ter_value)-P1;//variance of noise method2 +disp(P1,'Power of the additive noise') +f1 = acos(real(Z(1)))/(2*%pi) +disp(f1,'frequency of the additive noise') +disp(sigma_w1,'Variance of the additive noise') -- cgit