Matlab Butterworth filter returing NaN -


i trying apply butterworth filter in matlab. have set filter follows:

[z,p,k] = butter(5,[30/2000,1000/2000]);  

i.e. cut off below 30 hz , above 1000 hz (sampling @ 2000 hz)

the input data column in larger matrix, a.

i applying filter follows:

m=filter(z,p,a(:,2)); 

and have tried:

m=filtfilt(z,p,a(:,2)); 

a has 1577563 rows. filter returns real values around row ~1700 after entries nan. have tried extracting selection of values a(:,2) generate nan in m, on own, these return numbers, assuming length of a, rather specific values. seem instability in filter function, since start of nan differs on different tests.

i have tried reducing order, similar results 2nd , 1st order filters.

if there way happily upload data in a(:,2) not sure how in stackexchange.

i have perfect void idea of trying do. well, there huge issues on code , in concept:

  1. the butter frequencies must half sampling frequency. implementing 15hz , 500hz sampling @ 2000hz, im sure not need,

  2. you feeding filter command zpk -zero, pole, filter- structure, , 'filter' command receives b , a tf polynomials. can lead unpredictable wrong results,

  3. you cannot set bandpass between f0 , f1 when f1 nyquist, half sampling rate, fs/2. if so, use f0 , set filter highpass!. if still need bandpass, choose f1=900 or close, not very nyquist cut.

here corrected version, sampled filter between 30hz , 950hz, sampling @ 2000hz:

   x  = randn(500,1);     % input filter    [b,a] = butter(5,[30/2000,950/2000]*2);     y=filter(b,a,x);    fvtool(b,a);    plot([x y]); 

greetings!...


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -