Advertisement
makispaiktis

Butterworth

Feb 11th, 2021 (edited)
1,294
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 1.11 KB | None | 0 0
  1. clc
  2. clear all
  3.  
  4. % 1. For a specific value of "n", I have to find all the 2*n poles
  5.  
  6. display('******** 1. n ********');
  7. n = 2
  8. p = [];
  9. for k = 1 : 2*n
  10.     p(k) = exp(i * pi * (1 / 2 + (2*(k-1)-1) / (2*n)));
  11. end
  12.  
  13. display('******** 2. All the poles (p) of the square of norm: |Hn(s)|^2 ********');
  14. p
  15.  
  16. % 2. Now, I have 2*n poles in the list p and I have to keep only those
  17. % with the negative real part
  18.  
  19. poles = [];
  20. for k = 1 : length(p)
  21.     if real(p(k)) <= 0
  22.         poles(length(poles)+1) = p(k);
  23.     end
  24. end
  25.  
  26. display('******** 3. The poles with the negative real part (poles) ********');
  27. poles
  28.  
  29. % 3. Having the "poles" list, I have to calculate the Bn(s), then the
  30. % coefficients and then to siplay the Hn(s) function as a transfer function
  31. % here in Matlab
  32. syms s
  33. display('******** 4. Butterworth polynomial ********');
  34. Bn = (s - poles(1)) * (s - poles(2))
  35. display('******** 5. Coefficients of polynomial ********');
  36. coefficients = coeffs(Bn, 's')
  37.  
  38. c = []
  39. for index = 1:length(coefficients)
  40.     c(index) = coefficients(index);
  41. end
  42.  
  43. display('******** 6. Hn(s) = 1 / Bn(s) ********');
  44. Hn = tf([1], c)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement