Advertisement
milanmetal

[SIS] Vezba 6 z2

May 28th, 2017
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 3.73 KB | None | 0 0
  1. clear all
  2. clc
  3. %
  4. % RESENJE ZADATKA 2
  5. %
  6. % Specifikacija filtra
  7. n = 6;      % red filtra
  8. Rp = 1;     % dB
  9. Rs = 40;    % Rn = 40dB
  10. Wn = 14000; % rad / s
  11.  
  12. w = 0 : 10 : 2*Wn;
  13.  
  14.  
  15. % Projektovanje analognog filtra koriscenjem Cebisevljeve aproksimacije prve
  16. % vrste
  17. [b_cheby1,a_cheby1] = cheby1(n,Rp,Wn,'high','s')
  18. % Crtanje amplitudske  fazne karakteristike pomocu funkcije freqs
  19. figure
  20. % -----------------------------------
  21. % freqs returns the complex frequency response H(jω) (Laplace transform)
  22. % of an analog filter
  23. % given the numerator and denominator coefficients in vectors b and a.
  24. % -----------------------------------
  25. h = freqs(b_cheby1,a_cheby1, w);
  26. amplitudska_karakteristika = 20*log10(abs(h));
  27. fazna_karakteristika = 180/pi*angle(h);
  28.  
  29. % -----------------------------------
  30. % semilogx // Semilogarithmic plot
  31. %
  32. % - semilogx plot data as logarithmic scales for the x-axis.
  33. % - semilogx(Y) creates a plot using a base 10 logarithmic scale for
  34. %   the x-axis and a linear scale for the y-axis.
  35. % - It plots the columns of Y versus their index if Y contains real numbers.
  36. %   semilogx(Y) is equivalent to semilogx(real(Y),imag(Y))
  37. % - if Y contains complex numbers. semilogx ignores the imaginary
  38. %   component in all other uses of this function.
  39. % -----------------------------------
  40. subplot(2,1,1), semilogx(w,amplitudska_karakteristika);
  41. axis ([0 2*Wn -100 10]);
  42.  
  43. title (sprintf('Analogni filtar projektovan koriscenjem Cebisevljeve aproksimacije prve vrste\nAmplitudska karakteristika'));
  44. grid on
  45. subplot(2,1,2), semilogx(w,fazna_karakteristika)
  46. axis ([0 2*Wn -180 180]);
  47. title ('Fazna karakteristika');
  48. grid on
  49.  
  50.  
  51. % Projektovanje analognog filtra koriscenjem Cebisevljeve aproksimacije druge
  52. % vrste
  53. [b_cheby2,a_cheby2] = cheby2(n,Rs,Wn,'high','s');
  54. % Crtanje amplitudske  fazne karakteristike pomocu funkcije freqs
  55. figure
  56. h = freqs(b_cheby2,a_cheby2, w);
  57. amplitudska_karakteristika = 20*log10(abs(h));
  58. fazna_karakteristika = 180/pi*angle(h);
  59. subplot(2,1,1), semilogx(w,amplitudska_karakteristika)
  60. axis ([0 2*Wn -100 10]);
  61.  
  62. title (sprintf('Analogni filtar projektovan koriscenjem Cebisevljeve aproksimacije druge vrste\nAmplitudska karakteristika'));
  63. grid on
  64. subplot(2,1,2), semilogx(w,fazna_karakteristika)
  65. axis ([0 2*Wn -180 180]);
  66. title ('Fazna karakteristika');
  67. grid on
  68.  
  69.  
  70. % Projektovanje analognog filtra koriscenjem Batervortove aproksimacije
  71. [b_butter,a_butter] = butter(n,Wn,'high','s');
  72. % Crtanje amplitudske  fazne karakteristike pomocu funkcije freqs
  73. figure
  74. h = freqs(b_butter,a_butter, w);
  75. amplitudska_karakteristika = 20*log10(abs(h));
  76. fazna_karakteristika = 180/pi*angle(h);
  77. subplot(2,1,1), semilogx(w,amplitudska_karakteristika)
  78. axis ([0 2*Wn -100 10]);
  79. title (sprintf('Analogni filtar projektovan koriscenjem Batervortove aproksimacije\nAmplitudska karakteristika'));
  80. grid on
  81. subplot(2,1,2), semilogx(w,fazna_karakteristika)
  82. axis ([0 2*Wn -180 180]);
  83. title ('Fazna karakteristika');
  84. grid on
  85.  
  86.  
  87. % Projektovanje analognog filtra koriscenjem elipticke aproksimacije
  88. [b_ellip,a_ellip] = ellip(n,Rp,Rs,Wn,'high','s');
  89. % Crtanje amplitudske  fazne karakteristike pomocu funkcije freqs
  90. figure
  91. h = freqs(b_ellip,a_ellip, w);
  92. amplitudska_karakteristika = 20*log10(abs(h));
  93. fazna_karakteristika = 180/pi*angle(h);
  94. subplot(2,1,1), semilogx(w,amplitudska_karakteristika)
  95. axis ([0 2*Wn -100 10]);
  96. title (sprintf('Analogni filtar projektovan koriscenjem elipticke aproksimacije\nAmplitudska karakteristika'));
  97. grid on
  98. subplot(2,1,2), semilogx(w,fazna_karakteristika)
  99. axis ([0 2*Wn -180 180]);
  100. title ('Fazna karakteristika');
  101. grid on
  102.  
  103.  
  104. % Definisanje ulaznog signala za potrebe Simulink simulacije
  105. t = 0 : 0.00001 : 0.01;
  106. u = cos(2*pi*1000*t)+0.5*cos(2*pi*1800*t)+0.25*cos(2*pi*3000*t);
  107. u_sim = [t; u]';
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement