Guest User

Untitled

a guest
Oct 17th, 2018
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.70 KB | None | 0 0
  1. Aim : Write a Mat Lab Program for generation of Basic sequences like Unit Impulse, Unit Step, Unit Ramp, Exponential, Sine and Cosine.
  2.  
  3. %Program For Unit Impulse
  4. n=-2:2
  5. a=[zeros(1,2),ones(1,1),zeros(1,2)]
  6. subplot(3,2,1)
  7. stem(n,a)
  8. xlabel('n->')
  9. ylabel('Magnitude')
  10. title('Unit Impulse')
  11.  
  12. %Program For Unit Step
  13. n=-2:2
  14. a=[zeros(1,2),ones(1,3)]
  15. subplot(3,2,2)
  16. stem(n,a)
  17. xlabel('n->')
  18. ylabel('Magnitude')
  19. title('Unit Step')
  20.  
  21. %Program For Unit Ramp
  22. n=-2:3
  23. a=[zeros(1,2),0:3]
  24. subplot(3,2,3)
  25. stem(n,a)
  26. xlabel('n->')
  27. ylabel('Magnitude')
  28. title('Unit Ramp')
  29.  
  30. %Program For Exponential
  31. n=0:10
  32. a=0.5
  33. ans=a.^m
  34. subplot(3,2,4)
  35. stem(n,ans)
  36. xlabel('n->')
  37. ylabel('Magnitude')
  38. title('Exponential')
  39.  
  40. %Program For Sin
  41. n=-1:0.001:1
  42. a=sin(2*pi*n)
  43. subplot(3,2,5)
  44. plot(n,a)
  45. xlabel('n->')
  46. ylabel('Magnitude')
  47. title('Sine')
  48.  
  49. %Program For Cos
  50. n=-1:0.001:1
  51. a=cos(2*pi*n)
  52. subplot(3,2,6)
  53. plot(n,a)
  54. xlabel('n->')
  55. ylabel('mag')
  56. title('Cosin')
  57.  
  58. Aim : Write a Mat Lab Program to find convolution of two finite length Sequences.
  59. Program :
  60.  
  61. % Program for Convolution
  62. u=input('Enter 1st Sequence : ');
  63. v=input('Enter 2nd Sequence : ');
  64. u1=length(u)
  65. v1=length(v)
  66. dpx=0:u1-1
  67. dph=0:v1-1
  68.  
  69. subplot(2,2,1)
  70. stem(dpx,u)
  71. xlabel('n->')
  72. ylabel('Magnitude')
  73. title('1st Sequence')
  74.  
  75. subplot(2,2,2)
  76. stem(dph,v)
  77. xlabel('n->')
  78. ylabel('Magnitude')
  79. title('2nd Sequence')
  80.  
  81. y=conv(u,v)
  82. dpy=0:(u1+v1-2)
  83. subplot(2,2,[3,4])
  84. stem(dpy,y)
  85. xlabel('n->')
  86. ylabel('Magnitude')
  87. title('Convolution')
  88.  
  89. Aim : Write a Mat Lab Program to verify the properties of Z – Transform.
  90. i. Linearity
  91. ii. Scaling in Z Domain
  92. iii. Time Reversal
  93. iv. Differential in Z- Domain
  94.  
  95. Program :
  96.  
  97. % Program for Linearity
  98. syms n
  99. f= 2^n
  100. ztrans(f)
  101. g= 3^n
  102. ztrans(g)
  103. x=f+g
  104. ztrans(x)
  105.  
  106. % Program for Scaling in Z Domain
  107. syms a n w
  108. x1=(a^n)*cos(w.*n)
  109. ztrans(x1)
  110.  
  111. % Program for Time Reversal
  112. syms a n
  113. x2= (a^(-n))
  114. ztrans(x2)
  115.  
  116. % Program for Differential in Z Domain
  117. syms a n
  118. x3=n.*(a^n)
  119. ztrans(x3)
  120.  
  121.  
  122. Aim: Write a MATLAB program to design a low pas FIR filter using rectangular window.
  123.  
  124. Program:
  125. %Program to design a Low Pass FIR Filter using rectangular window
  126. %Taking Input
  127. rp =input('Enter Pass Band Ripple : ')
  128. rs=input('Enter Stop Band Ripple : ')
  129. fp=input('Enter Pass Band Frequency : ')
  130. fs=input('Enter Stop Band Frequency : ')
  131. f=input('Enter Sampling Frequency : ')
  132.  
  133. %Calculating Order
  134. wp=(2*fp)/f
  135. num= -20*log10(sqrt(rp*rs))
  136. den=14.6*(fs-fp)/f
  137. n=ceil(num/den)
  138. n1=n+1
  139.  
  140. %Odd value
  141. if(rem(n,2)~=0)
  142. n1=n
  143. n=n+1
  144. end
  145.  
  146. %Low Pass FIR Filter
  147. y=rectwin(n1)
  148. b=fir1(n,wp,y)
  149. [h,o]=freqz(b,1,256)
  150. m=20*log10(abs(h))
  151.  
  152. %Plotting Values
  153. plot(o/pi,m)
  154. xlabel('Normalized Frequency')
  155. ylabel('Gain in DB')
Add Comment
Please, Sign In to add comment