function [fout, h]=wiener_levinson(b,d); %WIENER_LEVINSON Shape the input vector to look like the desired output % The input and the desired output must be equal length column vectors. % % b is the input trace. % d is the desired output. % fout is the output of the filtering (actual output) % h is the wiener filter. % % This function uses the algorithm descibed in Robinson and Tritel's % Geophysical Signal Analysis (1981) on page 191. % % ac=xcorr(b); r1=ac(length(b):end); xc=xcorr(b,d); g1=xc(length(b):end); h=(glev(r1,g1)); % This solves the system R * h = g for the filter, h fout=conv(h,b); % Convolve the filter with the input trace fout=fout(1:length(b)); % trim the output to the same length as the input