%Se conoce el orden del filtro (n)
clc
clear all
close all
%Calculo de los coeficientes
%[b,a]=yulewalk(n,f,m);
fs=30000;
f1=1000;
f2=10000;
t=0:1/fs:1;
x1=sin(2*pi*f1*t);
x2=sin(2*pi*f2*t);
x=x1+x2;
N=1024;
X=fft(x,N);
f=(1:N/2)*fs/N;
figure(1)
plot(t,x)
figure(2)
plot(f,abs(X(1:N/2)))

%EJEMPLO DE YULEWALK
%[b,a] = yulewalk(n,f,m); 
ff = [0 1000 4000 15000]/15000;
m = [1 1 0 0];
[b,a] = yulewalk(8,ff,m);
[h,w] = freqz(b,a,128);
figure(3)
plot(ff,m,w/pi,abs(h),'--')
legend('Ideal','yulewalk Designed')
title('Comparison of Frequency Response Magnitudes')

x_filt=filter(b,a,x);   
figure(4)
plot(t,x_filt)
figure (5)
Y=fft(x_filt,N);
plot(f,abs(Y(1:N/2)))

