Shafayat__

Untitled

Aug 4th, 2023
247
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.94 KB | None | 0 0
  1. import numpy as np
  2.  
  3. STa = float(input('Stopband Attenuation: '))
  4. fc = 1.5
  5. delF = 0.5
  6. sF = 8
  7. Fcc = fc + (delF / 2) / sF
  8.  
  9. Wn1 = np.zeros(27)
  10. Wn2 = np.zeros(27)
  11. Wn3 = np.zeros(27)
  12. H = np.zeros(27)
  13. Hd = np.zeros(27)
  14. Hans = np.zeros(53)
  15. Hd[0] = 2 * Fcc
  16. Wn1[0] = 0.5 + 0.5 * np.cos(0)
  17. Wn2[0] = 0.54 + 0.46 * np.cos(0)
  18. Wn3[0] = 1
  19. H[0] = Hd[0] * Wn2[0]
  20.  
  21. for n in range(26):
  22.     Hd[n+1] = (np.sin(2 * np.pi * Fcc * (n+1))) / (np.pi * (n+1))
  23.  
  24. if 21 < STa <= 44:
  25.     for n in range(26):
  26.         Wn1[n+1] = 0.5 + 0.5 * np.cos((2 * np.pi * (n+1)) / 53)
  27.         H[n+1] = Hd[n+1] * Wn1[n+1]
  28.  
  29. if 44 < STa <= 53:
  30.     for n in range(26):
  31.         Wn2[n+1] = 0.54 + 0.46 * np.cos((2 * np.pi * (n+1)) / 53)
  32.         H[n+1] = Hd[n+1] * Wn2[n+1]
  33.  
  34. if STa <= 21:
  35.     for n in range(26):
  36.         Wn3[n+1] = 1
  37.         H[n+1] = Hd[n+1] * Wn3[n+1]
  38.  
  39. Hans[:27] = H[::-1]
  40. Hans[27:] = H[1:]
  41.  
  42. for f in range(1, 54):
  43.     print(f'h({f-1}): {Hans[f-1]:.4e}')
Advertisement
Add Comment
Please, Sign In to add comment