Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- clear all
- clc
- %
- % RESENJE ZADATKA 2
- %
- % Specifikacija filtra
- n = 6; % red filtra
- Rp = 1; % dB
- Rs = 40; % Rn = 40dB
- Wn = 14000; % rad / s
- w = 0 : 10 : 2*Wn;
- % Projektovanje analognog filtra koriscenjem Cebisevljeve aproksimacije prve
- % vrste
- [b_cheby1,a_cheby1] = cheby1(n,Rp,Wn,'high','s')
- % Crtanje amplitudske fazne karakteristike pomocu funkcije freqs
- figure
- % -----------------------------------
- % freqs returns the complex frequency response H(jω) (Laplace transform)
- % of an analog filter
- % given the numerator and denominator coefficients in vectors b and a.
- % -----------------------------------
- h = freqs(b_cheby1,a_cheby1, w);
- amplitudska_karakteristika = 20*log10(abs(h));
- fazna_karakteristika = 180/pi*angle(h);
- % -----------------------------------
- % semilogx // Semilogarithmic plot
- %
- % - semilogx plot data as logarithmic scales for the x-axis.
- % - semilogx(Y) creates a plot using a base 10 logarithmic scale for
- % the x-axis and a linear scale for the y-axis.
- % - It plots the columns of Y versus their index if Y contains real numbers.
- % semilogx(Y) is equivalent to semilogx(real(Y),imag(Y))
- % - if Y contains complex numbers. semilogx ignores the imaginary
- % component in all other uses of this function.
- % -----------------------------------
- subplot(2,1,1), semilogx(w,amplitudska_karakteristika);
- axis ([0 2*Wn -100 10]);
- title (sprintf('Analogni filtar projektovan koriscenjem Cebisevljeve aproksimacije prve vrste\nAmplitudska karakteristika'));
- grid on
- subplot(2,1,2), semilogx(w,fazna_karakteristika)
- axis ([0 2*Wn -180 180]);
- title ('Fazna karakteristika');
- grid on
- % Projektovanje analognog filtra koriscenjem Cebisevljeve aproksimacije druge
- % vrste
- [b_cheby2,a_cheby2] = cheby2(n,Rs,Wn,'high','s');
- % Crtanje amplitudske fazne karakteristike pomocu funkcije freqs
- figure
- h = freqs(b_cheby2,a_cheby2, w);
- amplitudska_karakteristika = 20*log10(abs(h));
- fazna_karakteristika = 180/pi*angle(h);
- subplot(2,1,1), semilogx(w,amplitudska_karakteristika)
- axis ([0 2*Wn -100 10]);
- title (sprintf('Analogni filtar projektovan koriscenjem Cebisevljeve aproksimacije druge vrste\nAmplitudska karakteristika'));
- grid on
- subplot(2,1,2), semilogx(w,fazna_karakteristika)
- axis ([0 2*Wn -180 180]);
- title ('Fazna karakteristika');
- grid on
- % Projektovanje analognog filtra koriscenjem Batervortove aproksimacije
- [b_butter,a_butter] = butter(n,Wn,'high','s');
- % Crtanje amplitudske fazne karakteristike pomocu funkcije freqs
- figure
- h = freqs(b_butter,a_butter, w);
- amplitudska_karakteristika = 20*log10(abs(h));
- fazna_karakteristika = 180/pi*angle(h);
- subplot(2,1,1), semilogx(w,amplitudska_karakteristika)
- axis ([0 2*Wn -100 10]);
- title (sprintf('Analogni filtar projektovan koriscenjem Batervortove aproksimacije\nAmplitudska karakteristika'));
- grid on
- subplot(2,1,2), semilogx(w,fazna_karakteristika)
- axis ([0 2*Wn -180 180]);
- title ('Fazna karakteristika');
- grid on
- % Projektovanje analognog filtra koriscenjem elipticke aproksimacije
- [b_ellip,a_ellip] = ellip(n,Rp,Rs,Wn,'high','s');
- % Crtanje amplitudske fazne karakteristike pomocu funkcije freqs
- figure
- h = freqs(b_ellip,a_ellip, w);
- amplitudska_karakteristika = 20*log10(abs(h));
- fazna_karakteristika = 180/pi*angle(h);
- subplot(2,1,1), semilogx(w,amplitudska_karakteristika)
- axis ([0 2*Wn -100 10]);
- title (sprintf('Analogni filtar projektovan koriscenjem elipticke aproksimacije\nAmplitudska karakteristika'));
- grid on
- subplot(2,1,2), semilogx(w,fazna_karakteristika)
- axis ([0 2*Wn -180 180]);
- title ('Fazna karakteristika');
- grid on
- % Definisanje ulaznog signala za potrebe Simulink simulacije
- t = 0 : 0.00001 : 0.01;
- u = cos(2*pi*1000*t)+0.5*cos(2*pi*1800*t)+0.25*cos(2*pi*3000*t);
- u_sim = [t; u]';
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement