matlab - Filter data using frequency model -


i filter time vector v using given frequency response. filer given set of 2 vectors: f , h, f frequency , h magnitude of response. cannot fft data v , multiply in frequency domain, since data v extremely large , ffting not feasible. i've tried yule-walker approach, doesn't fit data.

how can apply given frequency response on data?

perhaps try linear phase fir filter. can design such filter achieve desired frequency response, filter data using it.

let me first generate hypothetical f, h, , v solution contains working example:

n = 20;                  % (desired filter order)/2 fs = 50;                 % data sampling rate f = (0:n)'/n * (fs/2);   % freq filter response h = (f < 10);            % hypothetical low-pass filter t = (0:1000)'/fs; v = sin(t) + sin(2*pi*20*t);  % hypothetical data 

design fir filter using ifft

you can inverse fourier transform filter's frequency response obtain fir filter coefficients.

here, assuming f evenly spaced, starts @ 0, , ends @ nyquist frequency. if not case, maybe can interpolate f , h true. keep in mind resulting filter have length of 2*n, n = length(f)-1

since assuming symmetric real filter, filter should have same response negative frequencies. ifft expects frequencies start @ zero, though, these negative frequency responses aliased higher frequencies. assuming h column vector:

h_shifted = [h; flipud(h(2:end-1))]; 

then inverse transform , shift back:

b_shifted = ifft(h_shifted); b = [b_shifted(n+1:end); b_shifted(1:n)]; 

if have signal processing toolbox, can try designfilt gives few more options regards filter design.

filter data

now have filter coefficients, can use filter or fftfilt apply filter data. remember account filter delay. example:

v_padded = [v; zeros(n,1)]; y_padded = fftfilt(b, v_padded); y = y_padded(n+1:end); 

of course, if filtering data in blocks, should pad subsequent data instead of zeros :)


Comments

Popular posts from this blog

authentication - Mongodb revoke acccess to connect test database -

r - Update two sets of radiobuttons reactively - shiny -

ios - Realm over CoreData should I use NSFetchedResultController or a Dictionary? -