Горохов Сергей Экт-41
ВАРИАНТ 10 : 1/35,1/3,12 гц
clf; vn=25;
t=0:1/(vn):25;
x1=sin(2*pi*t/35); x2=sin(2*pi*t/3); x3=sin(2*pi*12*t);
x=x1+x2+x3;
subplot(311);plot(t,x1) subplot(312);plot(t,x1+x2) subplot(313);
plot(t,x) pause
%llh 1/35
N=300; Vs=0.3;
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 12
N1=40; Vs1=8;
b1=FIR1(N1,Vs1/vn,'high'); a1=[]; a1=[1 a1];
y1=FILTFILT(b1,a1,x); h1=abs(freqz(b1,a1,n));
%LF 1/35 1/3
N2=10; Vs2=8;
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 1/35 1/3
N3=2; Vs2=8;
[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');