
%
%Kesim frekans? 1 rad/sn olan AG filtrenin
% impulse invariant ve biliner d?m???mler ayr?kla?t?r?lmas? 
% LP to HP  ge?ip ayn? i?in yap?lmas?.....
% H(s)=[1]/[1 1.4112 1]
%
Pay_H_s=[1];
Payda_H_s=[1 1.4112 1];
Fs=40;


[H_jw_surekli_zaman, w_surekli_zaman]=freqs(Pay_H_s,Payda_H_s,512);
plot(w_surekli_zaman,abs(H_jw_surekli_zaman))
xlabel('w (rad/sn)')
title('Analog Filtre')

[Pay_H_z,Payda_H_z]=impinvar(Pay_H_s,Payda_H_s,Fs);
[H_jw_ayrik_zaman, w_ayrik_zaman]=freqz(Pay_H_z,Payda_H_z,512);
figure;
plot(Fs.*w_ayrik_zaman,abs(H_jw_ayrik_zaman))
xlabel('w');
%
%Karsilastirma:
plot(w_surekli_zaman,abs(H_jw_surekli_zaman),Fs.*w_ayrik_zaman,abs(H_jw_ayrik_zaman))


[Pay_H_z_bilinear,Payda_H_z_bilinear]=bilinear(Pay_H_s,Payda_H_s,Fs);
[H_jw_ayrik_zaman_bilinear, w_ayrik_zaman_bilinear]=freqz(Pay_H_z_bilinear,Payda_H_z_bilinear,512);

plot(w_surekli_zaman,abs(H_jw_surekli_zaman),Fs.*w_ayrik_zaman_bilinear,abs(H_jw_ayrik_zaman_bilinear))


%
% LP to HP d?n???m? ile filtrenin ayr?la?t?r?lmas?
%

[HP_Pay HP_Payda]=lp2hp(Pay_H_s,Payda_H_s,1);

[H_jw_surekli_zaman_HP, w_surekli_zaman_HP]=freqs(HP_Pay,HP_Payda,512);
plot(w_surekli_zaman_HP,abs(H_jw_surekli_zaman_HP))
xlabel('w (rad/sn)')
title('Analog Y?ksek Filtre')

[Pay_HP_H_z,Payda_HP_H_z]=impinvar(HP_Pay,HP_Payda,Fs);
[H_jw_ayrik_zaman_HP, w_ayrik_zaman_HP]=freqz(Pay_HP_H_z,Payda_HP_H_z,512);
figure;
plot(Fs.*w_ayrik_zaman_HP,abs(H_jw_ayrik_zaman_HP))
xlabel('w');
% Nicin sonuc elde edilemedi ???
%
% Bilinear d?n???m ile...
[Pay_H_z_HP_bilinear,Payda_H_z_HP_bilinear]=bilinear(HP_Pay,HP_Payda,Fs);
[H_jw_ayrik_zaman_HP_bilinear, w_ayrik_zaman_HP_bilinear]=freqz(Pay_H_z_HP_bilinear,Payda_H_z_HP_bilinear,512);

plot(w_surekli_zaman_HP,abs(H_jw_surekli_zaman_HP),Fs.*w_ayrik_zaman_HP_bilinear,abs(H_jw_ayrik_zaman_HP_bilinear),'x')

% AL?AK GEC?REN F?LTREN?N KES?M FREKANSI DE???T?R?LD?
%
% w_c=30 rad/sn olarak al?nd?.
%
[LP_Pay LP_Payda]=lp2lp(Pay_H_s,Payda_H_s,30);
[H_jw_surekli_zaman_LP, w_surekli_zaman_LP]=freqs(LP_Pay,LP_Payda,512);
plot(w_surekli_zaman_LP,abs(H_jw_surekli_zaman_LP))

[Pay_H_z_LP_bilinear,Payda_H_z_LP_bilinear]=bilinear(LP_Pay,LP_Payda,Fs);
[H_jw_ayrik_zaman_LP_bilinear, w_ayrik_zaman_LP_bilinear]=freqz(Pay_H_z_LP_bilinear,Payda_H_z_LP_bilinear,512);
plot(w_surekli_zaman_LP,abs(H_jw_surekli_zaman_LP),Fs.*w_ayrik_zaman_LP_bilinear,abs(H_jw_ayrik_zaman_LP_bilinear),'x')
%
% ni?in farkl?la?ma ba?lad? ?

