Documente Academic
Documente Profesional
Documente Cultură
Nacional
Semestre 2019A
Deber
Tema:
MI YULEWALK Realizado por:
-Christopher
Castro
-Diego
Díaz
-Mateo
Reyes
Grupo: GR 1
PLANTEAMIENTO DEL PROBLEMA
• Repetir el ejercicio, pero sin emplear la instrucción YULEWALK e implementando su
propia función.
Fmax=140;
fs=2.1*Fmax;
t=0:1/fs:5;
x=sin(2*pi*t*100)+sin(2*pi*t*120)+sin(2*pi*t*140);
nFFT=1024;
LongVentana= nFFT/4;
Solapamiento =LongVentana/2;
[P_welch_BB,F_welch_BB] = pwelch(x,LongVentana,Solapamiento,nFFT,fs);
subplot(4,1,1)
plot(F_welch_BB,P_welch_BB,'r')
orden=20;
f1=[0 100 105 110 140]/Fmax;
m1=[1 1 1 0 0];
[b1,a1]=SINyulewalk(orden,f1,m1)
senial_filtrada_uno=sinfilter(b1,a1,x);
[P_welch_BB_filt,F_welch_BB_filt]=
pwelch(senial_filtrada_uno,LongVentana,Solapamiento,nFFT,fs);
subplot(4,1,2)
plot(F_welch_BB_filt,P_welch_BB_filt,'r')
% 2. Filtrado del segundo tono:
f1=[0 110 115 120 125 130 140]/Fmax; m1=[0 0 1 1 1 0 0];
[b1,a1]=SINyulewalk(orden,f1,m1);
senial_filtrada_dos=sinfilter(b1,a1,x);
% Verificación: espectrode la señal filtrada:
[P_welch_BB_filt,F_welch_BB_filt]=
pwelch(senial_filtrada_dos,LongVentana,Solapamiento,nFFT,fs);
subplot(4,1,3)
plot(F_welch_BB_filt,P_welch_BB_filt,'r')
% 3. Filtrado del tercer tono:
f1=[0 110 115 120 125 130 140]/Fmax;
m1=[0 0 0 0 0 1 1]; [b1,a1]=SINyulewalk(orden,f1,m1);
senial_filtrada_tres=sinfilter(b1,a1,x);
% Verificación: espectrode la señal filtrada:
[P_welch_BB_filt,F_welch_BB_filt]=
pwelch(senial_filtrada_tres,LongVentana,Solapamiento,nFFT,fs);
subplot(4,1,4)
plot(F_welch_BB_filt,P_welch_BB_filt,'r')
RESULTADOS OBTENIDOS
Aquí se puede observar que se obtiene un resulatdo similar con las funciones implemetadas versus las
funciones de Matlab.
if (nargin > 3)
npt = signal.internal.sigcasttofloat(npt,'double','yulewalk','NPT',...
'allownumeric');
if round(2 .^ round(log(npt)/log(2))) ~= npt
% NPT is not an even power of two
npt = round(2.^ceil(log(npt)/log(2)));
end
end
if (nargin < 4)
npt = 512;
end
if (nargin < 5)
lap = fix(npt/25);
end
% Checks if LAP is a valid numeric input
lap = signal.internal.sigcasttofloat(lap,'double','yulewalk',...
'LAP','allownumeric');
[mf,nf] = size(ff);
[mm,nn] = size(aa);
if mm ~= mf || nn ~= nf
error(message('signal:yulewalk:InvalidDimensions'))
end
nbrk = max(mf,nf);
if mf < nf
ff = ff';
aa = aa';
end
nint=nbrk-1;
df = diff(ff');
if (any(df < 0))
error(message('signal:yulewalk:MonotonicFreq'))
end
nb = 1;
Ht(1)=aa(1);
for i=1:nint
if df(i) == 0
nb = nb - lap/2;
ne = nb + lap;
else
ne = fix(ff(i+1)*npt);
end
if (nb < 0 || ne > npt)
error(message('signal:yulewalk:SignalErr'))
end
j=nb:ne;
if ne == nb
inc = 0;
else
inc = (j-nb)/(ne-nb);
end
Ht(nb:ne) = inc*aa(i+1) + (1 - inc)*aa(i);
nb = ne + 1;
end
Ht = [Ht Ht(npt-1:-1:2)];
n = length(Ht);
n2 = fix((n+1)/2);
nb = na;
nr = 4*na;
nt = 0:1:nr-1;
R = real(ifft(Ht .* Ht));
function b = numf(h,a,nb)
%NUMF Find numerator B given impulse-response h of B/A and denominator A
% NB is the numerator order. This function is used by YULEWALK.
nh = max(size(h));
impr = filter(1,a,[1 zeros(1,nh-1)]);
b = h/toeplitz(impr,[1 zeros(1,nb)])';
function A = denf(R,na)
%DENF Compute denominator from covariances.
% A = DENF(R,NA) computes order NA denominator A from covariances
% R(0)...R(nr) using the Modified Yule-Walker method.
% This function is used by YULEWALK.
nr = max(size(R));
Rm = toeplitz(R(na+1:nr-1),R(na+1:-1:2));
Rhs = - R(na+2:nr);
A = [1 Rhs/Rm'];