% вариант 6 : 1/3,1/5, 8 гц
clf; vn=20;
t=0:1/(vn):25;
x1=sin(2*pi*t/3);
x2=sin(2*pi*t/5);
x3=sin(2*pi*8*t);
x=x1+x2+x3;
%llh 0.333
N=130; Vs=0.22;
b=FIR1(N,Vs/vn);
a=[]; a=[1 a];
n=256;
y=FILTFILT(b,a,x);
h=abs(freqz(b,a,n));
ff=(1/n)*(0:n-1);
%HF N1=8;
Vs1=5;
b1=FIR1(N1,Vs1/vn,'high');
a1=[]; a1=[1 a1];
y1=FILTFILT(b1,a1,x);
h1=abs(freqz(b1,a1,n));
%LF 0.3333 0.2
N2=50; Vs2=5;
b2=FIR1(N2,Vs2/vn);
a2=[]; a2=[1 a2];
y2=FILTFILT(b2,a2,x);
h2=abs(freqz(b2,a2,n));
ff=(1/n)*(0:n-1);
%LF butter 0.3333 0.2
N3=3; Vs2=5;
[b3,a3]=butter(N3,Vs2/vn);
y3=FILTFILT(b3,a3,x);
h3=abs(freqz(b3,a3,n));
ff=(1/n)*(0:n-1);
q1=[0 Vs/vn Vs/vn 1];
w1=[1 1 0 0];
q2=[0 Vs1/vn Vs1/vn 1];
w2=[1 1 0 0];
q3=[0 Vs2/vn Vs2/vn 1];
w3=[1 1 0 0];
q4=[0 Vs2/vn Vs2/vn 1];
w4=[0 0 1 1];
subplot(511), plot(t,x); title('ИСХОДНЫЙ СИГНАЛ','FontName','courier');
subplot(512), semilogx(ff,h,q1,w1);
subplot(513), plot(t,y);
subplot(514),plot(ff,h1,q4,w4);
subplot(515), plot(t,y1);xlabel('ВЕРХНЯЯ ЧАСТОТА','FontName','courier');
pause
subplot(411),plot(ff,h2,q2,w2);xlabel('N=10');title('ПЕРЕДАТОЧНОЯ ФУНКЦИЯ ФИЛЬТРА ','FontName','courier');
subplot(412),plot(t,y2);
subplot(413), plot(ff,h3,q3,w3);
subplot(414), plot(t,y3);xlabel('ОТФИЛЬТРОВАНЫЕ ДВА НИЖНИХ СИГНАЛА ПРИ ПОМОЩИ ФИЛЬТРА БАТЕРВОРДА ','FontName','courier');