Showing posts with label Digital Signal Processing. Show all posts
Showing posts with label Digital Signal Processing. Show all posts

State the condition for stability of LTI system and determine for the given discrete time system, h(n) = (0.3)^nu(n) + 5δ(n), is stable of not.

Condition for the stability of LTI system: LTI system is stable if its impulse response is absolutely summable i.e., finite.
k=|h(k)|<

h(n) = (0.3)nu(n) + 5δ(n)

k=
  [ (0.3)nu(n) + 5δ(n) ]
Since, u(n) = 1 n ≥0
                  = 0 n < 0
also, δ(n) = 1 n = 0
                = 0 otherwise
Therefore, limits of u(n) will be from 0 to ∞ and limits for δ(n) will be only 0.

n=00.3nu(n)+5|δ(n)|





Since, u(n) = 1, between 0 to ∞ and δ(n)n=0 = 1
n=00.3nn=0(5)
= 5 + 0.30 + 0.31 + 0.32 +0.33 + ...
= 5 + 1 + 0.3 + 0.3 + 0.32 + 0.33 + ...
= 5 + 1 / (1 - 0.3)
= 5 + 1 / 0.7
= (3.5 + 1) / 0.7
= 4.5 / 0.7
= 45 / 7

k=|h(k)| = 45 / 7 

Therefore, the system is stable.

Difference between IIR and FIR systems.

IIR FIR
Impulse response is infinite. Impulse response is finite.
May or may not be stable. Always stable.
Have sharp cut-off hence faster. Comparativelyy slow.
IIR is recursive. FIR is non-recursive.
Multi-rated signals are not supported in IIR. Multi-rated signals are supported in FIR.
Phase response is not linear. Phase response is linear.
IIR is comparatively less accurate. FIR is more accurate.
IIR consists of zero and poles. FIR consists of only zeros (Poles always lies on origin).
IIR requires less memory than FIR. FIR requires more memory than IIR.
y(n)=k=1Naky(nk)+k=1Mbkx(nk) y(n)=k=0Mbkx(nk)

Check for the following system is, i) Static or Dynamic, ii) Causal or Non-Causal, iii) Linear or Non-Linear, iv) Time Variant or Time Invariant, v) Stable or Unstable

a) y(n) = 2x(n-1) + x(2n)
  1. Static or Dynamic
  2. Since the system requires a previous value (n-1) to obtain the current value it needs a memory to store the previous values. Hence, a system is Dynamic.
  3. Causal or Non-Causal
  4. Since the system requires a future value x(2n) to obtain the current value, the system is Non-Causal.
  5. Linear or Non-Linear
  6. The system of linear is,
    T[a1x1(n) + a2x2(n)] = a1T[x1(n)] + a2T[x2(n)]
    Y3 = Y2 + Y1
    Y1 = 2x1(n-1) + x1(2n)
    Y2 = 2x2(n-1) + x2(2n)
    L.H.S = 2[a1x1(n-1) + a2x2(n-1)] + a1x1(2n) + a2x2(2n)
    R.H.S = a1[2x1(n-1) + x1(2n)] + a2[2x2(n-1) + x2(2n)]
    = 2a1x1(n-1) + 2a2x2(n-1) + a1x1(2n) + a2x2(2n)
    = L.H.S
    Therefore, system is Linear.
  7. Time Variant or Time Invariant
  8. y(n, k) = 2x(n-1-k) + x(2n - k)
    y(n-k) = 2x(n-k-1) + x(2(n-k))
    = 2x(n-k-1) + x(2n -2k)
    y(n, k) ≠ y(n-k)
    Therefore, System is Time Variant
  9. Stable or Unstable
  10. If n → ∞, input signal always remains finite thus input remains finite.
    The given system remains finite, ∴ System is stable
b) y(n) = a[x(n)]2 + bx(n)
  1. Static or Dynamic
  2. Since the system depends only on the present value it does not need any memory to store value. Therefore, the system is Static.
  3. Causal or Non-Causal
  4. Since the system depends only on present values it does not depend on any future value. Therefore, the system is Causal.
  5. Linear or Non-Linear
  6. The system of linear is,
    T[a1x1(n) + a2x2(n)] = a1T[x1(n)] + a2T[x2(n)]
    Y3 = Y2 + Y1
    Y1 = a[x1(n)]2 + bx1(n)
    Y2 = a[x2(n)]2 + bx2(n)
    L.H.S = a{[a1[x1(n)] + a2[x2(n)]}2
    R.H.S = a1{a[x1(n)]2 + bx1} + a2{a[x2(n)]2 + bx2}
    =aa1[x1(n)]2 + bx1(n) + aa2[x2(n)]2 + bx2(n)
    = a{a1[x1(n)]2 + a2[x2(n)]2} + b[a1x1(n) + a2x2(n)]
    ≠ L.H.S
    Therefore, system is Non-Linear.
  7. Time Variant or Time Invariant
  8. y(n, k) = a[x(n-k)]2 + bx(n-k)
    y(n-k) = a[x(n-k)]2 + bx(n-k)
    y(n, k) = y(n-k)
    Therefore, System is Time Invariant.
  9. Stable or Unstable
  10. If n → ∞, input signal always remains finite and input remains finite too.
    The given system remains finite, ∴ System is stable

Cross Correlation in C | Digital Signal Processing

#include<stdio.h>
#include<graphics.h>
int m,n,x[30],h[30],y[30],i,j, k,x2[30],a[30],p,rh2[30];
void main()
{
int gd=DETECT,gm,option;
int Y=0,X=200,A=0;
printf(" enter the length of the first sequence\n");
scanf("%d",&m);
printf(" enter the length of the second sequence\n");
scanf("%d",&n);
printf(" enter the first sequence\n");
for(i=0;i<m;i++)
scanf("%d",&x[i]);
printf(" enter the second sequence\n");
for(j=0;j<n;j++)
{
scanf("%d",&h[j]);
rh2[j]=h[-j];
}
/*If length of both sequences are not equal*/
/* Pad the smaller sequence with zero*/
p=m+n-1;
for(i=n;i<p;i++)
{
h[i]=0;
}
for(i=m;i<p;i++)
{
x[i]=0;
}
y[0]=0;
a[0]=h[0];
for(j=1;j<p;j++) /*folding h(n) to h(-n)*/
a[j]=h[p-j];
/*Circular convolution*/
for(i=0;i<p;i++)
y[0]+=x[i]*a[i];
for(k=1;k<p;k++)
{
y[k]=0;
/*circular shift*/

for(j=1;j<p;j++)
x2[j]=a[j-1];
x2[0]=a[p-1];
for(i=0;i<p;i++)
{
a[i]=x2[i];
y[k]+=x[i]*x2[i];
}
}
/*displaying the result*/
printf(" the circular convolution is\n");
for(i=0;i<p;i++)
{printf("%d \t",y[i]);}
initgraph(&gd,&gm,NULL);
line(100,300,500,300);
for(i=0;i<p;i++)
{
A=y[i]*10;
if(A>=0)
{
for(j=0;j<=A;j++)
{
Y=(300+j)-y[i]*10;
putpixel(X,Y,WHITE);
}
}
else
{
for(j=0;j>=A;j--)
{
Y=(300+j)-y[i]*10;
putpixel(X,Y,WHITE);
}}
X=X+20;
}
delay(50000);
closegraph();
}

For document (code + output) kindly click here

Carl's Correlation Coefficient Algorithm











  • To measure the degree of linear dependence between two variable, Pearson Product Moment Correlation Coefficient (PPMCC) is used. This coefficient was developed by Carl Peasron.
  • This coefficient gives Statistical measurement of linear relationship between paired data.
  • This coefficient is denoted by 'r' and it is in the range, -1 ≤  r ≤ +1.
  • If value of 'r' is positive, then it gives positive linear correlation.
  • If value of 'r' is negative, then it gives negative linear correlation.
  • And if r = 0, then it indicates that there is no linear correlation.
  • The range of 'r' is from -1 to +1, so if the value of r is closer to +1 or -1 then it indicates stranger positive and negative linear correlation.
  • When the Pearson's correlation coefficient is applied to population then it is called as population pearson correlation coefficient and it is denoted by ρ (rho).
  • This coefficient is given by,
                           ρx,y =  COV (X, Y)σxσy              ...(1)
                 
         Here, COV(X,Y) denotes the covariance between X and Y.
              σx and  σy denotes standard deviation of X and Y respectively.

  • In terms of expectations (E), equation (1) can be written as,
                    ρx,y     =          E(X, Y) - E(X).E(Y)           
                                       E(X2) - E(X)2 . E(Y2) - E(Y)2


  • Consider that, we have the data sets (x1 , x2 , x3 , ..., xn ) and (y1 , y2 , y3 , ...yn ), contain n samples then the correlation coefficient is denoted by r and it is given by, 
                              

  • Here x̄ and ȳ denote the sample mean and given by,
           x̄  =   1  Σxi        and        ȳ =  1   Σyi                  (from i = 1 to n)
                n                             n
                            

State the DFT properties.

1) Periodicity
    If a sequence x(n) is periodic with a periodicity of N samples, then N-point DFT of the sequence is also periodic with a periodicity of N samples.
Hence, if x(n) and x(k) are on N-point DFT pair then
x(n + N) = x(n)      for all n
X(k + N) = X(k)     for all k

2) Linearity
    If x1(n) ↔ X1(k) and  x2(n) ↔ X2(k) then for any real valued or complex valued constants a1 and a2
a1x1(n) + a2x2(n) ↔ a1X2(K) + a2X2(K)

3) Parseval's Theorem
    For complex-valued sequences x(n) and y(n)
If x(n) ↔ X(k) and y(n) ↔ Y(k) then ,
n=0N1x(n).y*(n)=1Nk=0N1X(k).Y*(k)
If x(n) = y(n),
n=0N1|x(n)|2=1Nk=0N1|X(k)|2

4) Time Reversal
    If x(n) ↔ X(k) then x((-n)N = x(N-n) ↔ X((-k))N = X(N-k)
Hence, reversing the N-point sequence in time is equivalent to reversing the DFT values.

5) Symmetry
    Let assume that N-point sequence x(n) and its DFT are complex valued then,
x(n) = xR(n) + j xI(n)    0 ≤  n ≤  N-1
X(k) = xR(k) + j XI(k)    0 ≤  k ≤  N-1
where,
xR(n)=1Nn=0N1[XR(k)cos(2πknN)XI(k)sin(2πknN)]
xI(n)=1Nn=0N1[XR(k)sin(2πknN)+XI(k)cos(2πknN)]
Similarly,
XR(k)=n=0N1[xR(n)cos(2πknN)+xI(n)sin(2πknN)]
XI(k)=n=0N1[xR(n)sin(2πknN)xI(n)cos(2πknN)]
6) Time Shift
    If x(n) ↔ X(k) then
x(n - l)N ↔ X(k) e(-j2πkl)/N

7) Frequency Shift
    If x(n) ↔ X(k) then
X(k) e(j2πkl)/N ↔ X((k-l))N

8) Convolution (Multiplication of 2 DFT's)
    x(n).y(n) ↔ X(k).Y(k)