Problema con el ruido blanco
Hola Ok
Le comento
El programa consta de 3 script testwola.m, WOLA_analisis,WOLA_sintesis,WOLA_configuracion
Mi test_wola
function testWOLA()
%TESTWOLA Test WOLA.
close all;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Genera senal de prueba
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%fs = 16000;
[x, fs ] = wavread('hola.wav');
t = 0:1/fs:1;
%x = cos(2*pi*250*t) + 0.8*cos(2*pi*500*t) + 0.4*cos(2*pi*750*t);
% Genera Ruido blanco
L1 = length(t);
disp (L1);
disp(x);
var = 2; % varianza
k = randn(1,L1); % ruido no uniforme
mean1 = 0.0; % media
ruido = mean1 + (sqrt(var)*k); % ruido blanco
%ruido = awgn(x,20);
x=ruido;
B=floor(length(x)/256);
wavplay(x,fs);
for i=1:B,x(256*(i-1)+1:i*256) = x(1:256); end;
figure;
n=8192;
f= (0:n/2-1)*fs/n;
xf= abs(fft(x(1:n/8),n));
plot(f, xf(1:n/2));
axis([-100 1500 0 max(xf)]);
% Dibuja espectro
xf = abs(fft(x(1:1024),8192));
figure;
plot((0:4095)*fs/8192,xf(1:4096));
xlabel('Frecuencia (Hz)');
title('Senal entrada');
axis([-100 1500 0 max(xf)]);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Configura banco del filtros WOLA
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
L = 256; % Ventana de analisis (filtro prototipo)
N = 64; % 32 canales (N/2) (o 33, si es EVEN)
R = 32; % Long bloques de entrada (esto da un OS = N/R = 2)
DF = 2; % Factor de diezmado en sintesis
stacking = 'EVEN'; % Disposicion EVEN (primer filtro centrado en 0 Hz)
WOLAconfiguration = WOLA_configuration(L,N,R,DF,stacking);
% Dibuja respuesta en frecuencia
hf = abs(fft(WOLAconfiguration.W,8192))';
hhff = zeros(8192,N/2+1);
for i=0:N/2,
hhff(:,i+1) = circshift(hf,i*128);
end
figure;
plot((0:4095)*fs/8192,hhff(1:4096,:));
xlabel('Frecuencia (Hz)');
title('Respuestra banco de filtros WOLA');
axis([-100 1500 0 1.2]);
hold on;
text((0:5)*250, ones(1,6)+0.05, ...
{'Canal 1','Canal 2','Canal 3','Canal 4','Canal 5','Canal 6 ...'},...
'HorizontalAlignment','center');
%%%%%%%%%%%%%%
% Filtrado
%%%%%%%%%%%%%%
y = WOLA_analisis(x,WOLAconfiguration);
%Muestra los coeficientes de la ventana de análisis
for i=1:256, fprintf(' dc %0.8f\n',WOLAconfiguration.W(i));
end
%Anula una banda
%y(3,:)=0;
%%%%%%%%%%%%%%%%%%%%%%%%%
% Reconstruccion
%%%%%%%%%%%%%%%%%%%%%%%%%
xs = WOLA_sintesis(y,WOLAconfiguration);
% Dibuja senales de entrada y reconstruida
figure;
final = abs(fft(xs(1:1024),8192));
plot((0:4095)*fs/8192,final(1:4096));
xlabel('Frecuencia (Hz)');
title('Senal entrada');
axis([-100 1500 0 max(final)]);
figure;
plot(x,'b');
hold on;
plot(xs * max(x)/max(xs),'r');
axis([400 700 -2 3]);
legend('x(t) - original','xs(t) - reconstruida');
xlabel('Muestra');
resul=(xs * max(x)/max(xs));
wavwrite(resul,fs,16,'sonido_uno.wav');
wavplay(resul,fs);
AHORA SI EJECUTO NO DA PROBLEMAS PERO LA SEÑAL QUE TENGO X ME LA DESTRUYE
SI MODIFICO MI TEST_WOLA POR ESTO
SOLO LA PARTE DEL RUIDO
% Genera Ruido blanco
L1 = length(t);
disp (L1);
disp(x);
var = 2; % varianza
k = randn(1,L1); % ruido no uniforme
mean1 = 0.0; % media
%ruido = mean1 + (sqrt(var)*k); % ruido blanco
ruido = awgn(x,20);
x=ruido;
DA ERROR EN LO SIGUIENTE
Error using horzcat
CAT arguments dimensions are not consistent.
Error in WOLA_analisis (line 22)
buffer = [buffer(R+1:L) xinput];
Error in testWOLA (line 79)
y = WOLA_analisis(x,WOLAconfiguration);
LE PASO LA PARTE DEL WOLA_ANALISIS
function y = WOLA_analisis(x,WOLAconfiguration)
%WOLA_ANALISIS Analisis WOLA.
% Y = WOLA_ANALISIS(X,WCONF) descompone X con banco
% de filtros WOLA.
N = WOLAconfiguration.N;
L = WOLAconfiguration.L;
R = WOLAconfiguration.R;
OS = WOLAconfiguration.OS;
W = WOLAconfiguration.W;
numBlcks = floor(length(x)/R);
buffer = zeros(L);
y = zeros(N/2+1,numBlcks);
for i=1:numBlcks,
xinput = x((i-1)*R+1:i*R);
disp(xinput);
disp(L);
disp(R);
buffer = [buffer(R+1:L) xinput];
vector = reshape(buffer.*W,N,L/N);
inputfft = sum(vector,2);
inputfft = circshift(inputfft,mod(1,OS)*R);
outputfft = fft(inputfft);
y(:,i) = outputfft(1:N/2+1);
end
ME PUEDE AYUDAR QUE ESTOY LOCO Y NO DOY CON LA SOLUCCION
ESPERO SU RESPUESTA