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 --- 2294/CH2/EX2.2/EX2_2.sce | 51 ++++++++++++++++++++++++++++++ 2294/CH2/EX2.3/EX2_3.sce | 73 ++++++++++++++++++++++++++++++++++++++++++ 2294/CH2/EX2.4/EX2_4.sce | 60 +++++++++++++++++++++++++++++++++++ 2294/CH2/EX2.5/EX2_5.sce | 71 +++++++++++++++++++++++++++++++++++++++++ 2294/CH2/EX2.7/EX2_7.sce | 82 ++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 337 insertions(+) create mode 100755 2294/CH2/EX2.2/EX2_2.sce create mode 100755 2294/CH2/EX2.3/EX2_3.sce create mode 100755 2294/CH2/EX2.4/EX2_4.sce create mode 100755 2294/CH2/EX2.5/EX2_5.sce create mode 100755 2294/CH2/EX2.7/EX2_7.sce (limited to '2294/CH2') diff --git a/2294/CH2/EX2.2/EX2_2.sce b/2294/CH2/EX2.2/EX2_2.sce new file mode 100755 index 000000000..ff901b05e --- /dev/null +++ b/2294/CH2/EX2.2/EX2_2.sce @@ -0,0 +1,51 @@ +//Example 2.2 +//Find whether the given signal is causal or not. +clear all; +clc; +n=10;x1(1)=1;x2(1)=1; +for i=2:length(n) + x1(i)=i; + x2(i)=i-1; + y(i)=x1(i)+1 ./x2(i); + end +causal=%t; +for i=1:length(n) + if n(i)<0 &y(i)~=0 then + causal=%f; + end +end +disp(causal,"The statement that the system is causal is:"); +//Example 2.2 +//Find whether the given signal is causal or not. +clear all; +clc; +n=10;x1(1)=1;x2(1)=-1; +for i=2:length(n) + x1(i)=i; + x2(i)=i-2; + y(i)=x1(i).*x1(i)+x2(i); + end +causal=%t; +for i=1:length(n) + if n(i)<0 &y(i)~=0 then + causal=%f; + end +end +disp(causal,"The statement that the system is causal is:"); +//Example 2.2 +//Find whether the given signal is causal or not. +clear all; +clc; +n=-10:10; +for i=1:length(n) + x(i)=i; + y(i)=(i.^2); + end +causal=%t; +for i=1:length(n) + if n(i)<0 &y(i)~=0 then + causal=%f; + end +end +disp(causal,"The statement that the system is causal is:"); + diff --git a/2294/CH2/EX2.3/EX2_3.sce b/2294/CH2/EX2.3/EX2_3.sce new file mode 100755 index 000000000..6df614b7a --- /dev/null +++ b/2294/CH2/EX2.3/EX2_3.sce @@ -0,0 +1,73 @@ +//Example 2.3 +//Check whether the following signal is linear or not. +clear; +close; +clc; +T=20;//length of the signal +A=5; +B=4; +for n=1:T + x(n)=n; + y(n)=A*x(n)+B; +end +x1=x; +y1=y; +for n=1:T + x2(n)=2;y2(n)=A*x2(n)+B; +end +z=y1+y2; +for n=1:T + y3(n)=A*(x1(n)+x2(n))+B; +end +if z==y3 then + disp('The following signal is linear'); +else + disp('The following signal is non linear'); +end +//Example 2.3 +//Check whether the following signal is linear or not. +clear; +close; +clc; +T=20;//length of the signal +x1(1)=1; +x2(1)=2; +for n=2:T + x1(n)=n; + x2(n)=2*n; + y1(n)=(2*(x1(n)))+(1/x1(n-1)); + y2(n)=(2*(x2(n)))+(1/x2(n-1)); +end +z=y1+y2; +for n=2:T + y3(n)=(2*(x1(n)+x2(n)))+(1/(x1(n-1)+x2(n-1))); +end +if z==y3 then + disp('The following signal is linear'); +else + disp('The following signal is non linear'); +end +//Example 2.3 +//Check whether the following signal is linear or not. +clear; +close; +clc; +T=20;//length of the signal +for n=1:T + x(n)=n; + y(n)=n*x(n); +end +x1=x; +y1=y; +for n=1:T + x2(n)=2;y2(n)=n*x2(n); +end +z=y1+y2; +for n=1:T + y3(n)=n*(x1(n)+x2(n)); +end +if z==y3 then + disp('The following signal is linear'); +else + disp('The following signal is non linear'); +end diff --git a/2294/CH2/EX2.4/EX2_4.sce b/2294/CH2/EX2.4/EX2_4.sce new file mode 100755 index 000000000..d4bc27575 --- /dev/null +++ b/2294/CH2/EX2.4/EX2_4.sce @@ -0,0 +1,60 @@ +//Example 2.4 +//Check whether the following signal is linear or not. +clear; +close; +clc; +T=20;//length of the signal +for n=1:T + x1(n)=n;x2(n)=2*n; + y1(n)=exp(x1(n)); + y2(n)=exp(x2(n)); +end +z=y1+y2; +for n=1:T + y3(n)=exp(x1(n)+x2(n)); +end +if z==y3 then + disp('The following signal is linear'); +else + disp('The following signal is non linear'); +end +//Example 2.4 +//Check whether the following signal is linear or not. +clear; +close; +clc; +T=20;//length of the signal +for n=1:T + x1(n)=n;x2(n)=2*n; + y1(n)=x1(n)*x1(n); + y2(n)=x2(n)*x2(n); +end +z=y1+y2; +for n=1:T + y3(n)=(x1(n)+x2(n))^2; +end +if z==y3 then + disp('The following signal is linear'); +else + disp('The following signal is non linear'); +end +//Example 2.4 +//Check whether the following signal is linear or not. +clear; +close; +clc; +T=20;//length of the signal +for n=1:T + x1(n)=n;x2(n)=2*n; + y1(n)=n^2*(x1(n)); + y2(n)=n^2*(x2(n)); +end +z=y1+y2; +for n=1:T + y3(n)=n^2*(x1(n)+x2(n)); +end +if z==y3 then + disp('The following signal is linear'); +else + disp('The following signal is non linear'); +end diff --git a/2294/CH2/EX2.5/EX2_5.sce b/2294/CH2/EX2.5/EX2_5.sce new file mode 100755 index 000000000..338063db3 --- /dev/null +++ b/2294/CH2/EX2.5/EX2_5.sce @@ -0,0 +1,71 @@ +//Example 2.5 +//Determine whether the following system is time invariant or not. +clc; +clear all; +T=20;//length of the signal. +s=2;//shift +for n=1:T + x(n)=n; + y(n)=n*x(n); +end +IP=x(T-s); +OP=y(T-s); +if IP==OP then + disp('The given system is time invariant'); +else + disp('The given system is time variant'); +end +//Example 2.5 +//Determine whether the following system is time invariant or not. +clc; +clear all; +T=-10:10;//length of the signal. +s=2;//shift +for n=1:length(T) + x(n)=2; + y(n)=x(n)*cos(50*%pi.*T(n)); +end +IP=x(T(n)-s); +OP=y(T(n)-s); +if IP==OP then + disp('The given system is time invariant'); +else + disp('The given system is time variant'); +end +//Example 2.5 +//Determine whether the following signal is time invariant or not. +clc; +clear all; +N=10; +s=1//shift; +k=2; +for n=1:N + x(n)=n; +end +for n=1:(N/k) + y(n)=x(k*n); +end +ip=x(N-s); +op=y((N/k)-s); +if(ip==op) then + disp('the following signal is time invariant'); +else + disp('The given signal is time variant'); +//Example 2.5 +//Determine whether the following signal is time invariant or not. +clc; +clear all; +T=20; +s=4;//shift +x(1)=1 +for n=2:T + x(n)=n; + y(n)=x(n-1).*x(n-1); +end +inputshift=x(T-s); +outputshift=y(T-s); +if (inputshift==outputshift) then + disp('The given signal is time invariant'); +else + disp('The given signal is time variant'); +end diff --git a/2294/CH2/EX2.7/EX2_7.sce b/2294/CH2/EX2.7/EX2_7.sce new file mode 100755 index 000000000..966088cce --- /dev/null +++ b/2294/CH2/EX2.7/EX2_7.sce @@ -0,0 +1,82 @@ +//Check for the following system. +//Example 2.7 +clc; +clear ;//a>check whether static or dynamic +t=-10:.1:10;T=length(t) +s=2; +for i=1:length(t) + x(i)=i; + y(i)=abs(x(i)); +end +if y(2)==x(2)& y(2)==x(1) then + disp('The given signal is dynamic' ); +else + disp('the given signal is static'); +end +//b>check whether linear or non linear +x1=x; +y1=y; +for i=1:length(t) + x2(i)=-2; + y2(i)=abs(x2(i)); +end +for i=1:length(t) +z(i)=y1(i)+y2(i); +end +for i=1:length(t) + y3(i)=abs(x1(i)+x2(i)); +end +if z==y3 then + disp('The given signal is linear'); +else + disp('Not linear'); +end +//c>check whether time invariant or not +IP=x(T-s); +OP=y(T-s); +if IP == OP then +disp('the given signal is time invariant'); +else + disp('The given signal is not time invariant'); + end +//Check for the following systems +//Example 2.7 +clc; +clear all;//a>check whether static or dynamic +t=0:5;T=length(t);w=1; +s=2; +for i=1:length(t) + x(i)=i; + y(i)=x(i)*cos(w*t(i)); +end +if y(2)==x(2)& y(2)==x(1) then + disp('The given signal is dynamic' ); +else + disp('the given signal is static'); +end +//b>check whether linear or non linear +x1=x; +y1=y; +for i=1:length(t) + x2(i)=2*i; + y2(i)=x2(i)*cos(w*t(i)); + y3(i)=cos(w*t(i))*(x1(i)+x2(i)); +end +z=y1+y2; +if z~=y3 then + disp('The given signal is not linear'); +else + disp('linear'); +end +//c>check whether time invariant or not +IP=x(T-s); +OP=y(T-s); +if IP == OP then +disp('the given signal is time invariant'); +else + disp('The given signal is not time invariant'); + end + + + + -- cgit